fix custom functions inheriting other functions' arguments
Task-number: QTBUG-41830 Change-Id: Iba3eee4975a1ee671b7190e52c0efc9a18147c62 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
1b4ea11332
commit
dacf3994ba
@ -1809,19 +1809,35 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringLis
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool isFunctParam(const ProKey &variableName)
|
||||||
|
{
|
||||||
|
const int len = variableName.size();
|
||||||
|
const QChar *data = variableName.constData();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
ushort c = data[i].unicode();
|
||||||
|
if (c < '0' || c > '9')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ProValueMap *QMakeEvaluator::findValues(const ProKey &variableName, ProValueMap::Iterator *rit)
|
ProValueMap *QMakeEvaluator::findValues(const ProKey &variableName, ProValueMap::Iterator *rit)
|
||||||
{
|
{
|
||||||
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
||||||
do {
|
for (bool first = true; ; first = false) {
|
||||||
--vmi;
|
--vmi;
|
||||||
ProValueMap::Iterator it = (*vmi).find(variableName);
|
ProValueMap::Iterator it = (*vmi).find(variableName);
|
||||||
if (it != (*vmi).end()) {
|
if (it != (*vmi).end()) {
|
||||||
if (it->constBegin() == statics.fakeValue.constBegin())
|
if (it->constBegin() == statics.fakeValue.constBegin())
|
||||||
return 0;
|
break;
|
||||||
*rit = it;
|
*rit = it;
|
||||||
return &(*vmi);
|
return &(*vmi);
|
||||||
}
|
}
|
||||||
} while (vmi != m_valuemapStack.begin());
|
if (vmi == m_valuemapStack.begin())
|
||||||
|
break;
|
||||||
|
if (first && isFunctParam(variableName))
|
||||||
|
break;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1833,18 +1849,20 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName)
|
|||||||
it->clear();
|
it->clear();
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
if (!isFunctParam(variableName)) {
|
||||||
if (--vmi != m_valuemapStack.begin()) {
|
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
||||||
do {
|
if (--vmi != m_valuemapStack.begin()) {
|
||||||
--vmi;
|
do {
|
||||||
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
|
--vmi;
|
||||||
if (it != (*vmi).constEnd()) {
|
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
|
||||||
ProStringList &ret = m_valuemapStack.top()[variableName];
|
if (it != (*vmi).constEnd()) {
|
||||||
if (it->constBegin() != statics.fakeValue.constBegin())
|
ProStringList &ret = m_valuemapStack.top()[variableName];
|
||||||
ret = *it;
|
if (it->constBegin() != statics.fakeValue.constBegin())
|
||||||
return ret;
|
ret = *it;
|
||||||
}
|
return ret;
|
||||||
} while (vmi != m_valuemapStack.begin());
|
}
|
||||||
|
} while (vmi != m_valuemapStack.begin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return m_valuemapStack.top()[variableName];
|
return m_valuemapStack.top()[variableName];
|
||||||
}
|
}
|
||||||
@ -1852,7 +1870,7 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName)
|
|||||||
ProStringList QMakeEvaluator::values(const ProKey &variableName) const
|
ProStringList QMakeEvaluator::values(const ProKey &variableName) const
|
||||||
{
|
{
|
||||||
ProValueMapStack::ConstIterator vmi = m_valuemapStack.constEnd();
|
ProValueMapStack::ConstIterator vmi = m_valuemapStack.constEnd();
|
||||||
do {
|
for (bool first = true; ; first = false) {
|
||||||
--vmi;
|
--vmi;
|
||||||
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
|
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
|
||||||
if (it != (*vmi).constEnd()) {
|
if (it != (*vmi).constEnd()) {
|
||||||
@ -1860,7 +1878,11 @@ ProStringList QMakeEvaluator::values(const ProKey &variableName) const
|
|||||||
break;
|
break;
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
} while (vmi != m_valuemapStack.constBegin());
|
if (vmi == m_valuemapStack.constBegin())
|
||||||
|
break;
|
||||||
|
if (first && isFunctParam(variableName))
|
||||||
|
break;
|
||||||
|
}
|
||||||
return ProStringList();
|
return ProStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,6 +599,23 @@ void tst_qmakelib::addControlStructs()
|
|||||||
<< ""
|
<< ""
|
||||||
<< true;
|
<< true;
|
||||||
|
|
||||||
|
QTest::newRow("function arguments")
|
||||||
|
<< "defineTest(func) {\n"
|
||||||
|
"defined(1, var) {\nd1 = 1\nexport(d1)\n}\n"
|
||||||
|
"defined(3, var) {\nd3 = 1\nexport(d3)\n}\n"
|
||||||
|
"x1 = $$1\nexport(x1)\n"
|
||||||
|
"2 += foo\nx2 = $$2\nexport(x2)\n"
|
||||||
|
"x3 = $$3\nexport(x3)\n"
|
||||||
|
"4 += foo\nx4 = $$4\nexport(x4)\n"
|
||||||
|
"x5 = $$5\nexport(x5)\n"
|
||||||
|
"6 += foo\nx6 = $$6\nexport(x6)\n"
|
||||||
|
"}\n"
|
||||||
|
"1 = first\n2 = second\n3 = third\n4 = fourth\nfunc(one, two)"
|
||||||
|
<< "1 = first\n2 = second\n3 = third\n4 = fourth\n5 = UNDEF\n6 = UNDEF\n"
|
||||||
|
"d1 = 1\nd3 = UNDEF\nx1 = one\nx2 = two foo\nx3 =\nx4 = foo\nx5 =\nx6 = foo"
|
||||||
|
<< ""
|
||||||
|
<< true;
|
||||||
|
|
||||||
QTest::newRow("ARGC and ARGS")
|
QTest::newRow("ARGC and ARGS")
|
||||||
<< "defineTest(func) {\n"
|
<< "defineTest(func) {\n"
|
||||||
"export(ARGC)\n"
|
"export(ARGC)\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user