Commit 40116cc7 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

don't make an even number of bangs almost entirely invisible



otherwise we'd silently accept this nonsensical code:
  !!defineTest(foo) {}

Change-Id: I66b59c8a89852c6451ce8d7269a3dc66a53e3b1f
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
(cherry picked from qtbase/b7e839fbbd366863292566afbe736d7432d439ea)
parent 0a3b1792
......@@ -340,7 +340,7 @@ void QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar gra
m_canElse = false;
freshLine:
m_state = StNew;
m_invert = false;
m_invert = 0;
m_operator = NoOperator;
m_markLine = m_lineNo;
m_inError = false;
......@@ -623,7 +623,7 @@ void QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar gra
quote = 0;
goto nextChr;
} else if (c == '!' && ptr == xprPtr && context == CtxTest) {
m_invert ^= true;
m_invert++;
goto nextChr;
}
} else if (c == '\'' || c == '"') {
......@@ -686,7 +686,7 @@ void QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar gra
term = ':';
goto funcCall;
} else if (c == '!' && ptr == xprPtr) {
m_invert ^= true;
m_invert++;
goto nextChr;
} else if (c == ':') {
FLUSH_LHS_LITERAL();
......@@ -943,7 +943,7 @@ void QMakeParser::warnOperator(const char *msg)
{
if (m_invert) {
languageWarning(fL1S("Stray NOT operator %1.").arg(fL1S(msg)));
m_invert = false;
m_invert = 0;
}
if (m_operator == AndOperator) {
languageWarning(fL1S("Stray AND operator %1.").arg(fL1S(msg)));
......@@ -959,7 +959,7 @@ bool QMakeParser::failOperator(const char *msg)
bool fail = false;
if (m_invert) {
parseError(fL1S("Unexpected NOT operator %1.").arg(fL1S(msg)));
m_invert = false;
m_invert = 0;
fail = true;
}
if (m_operator == AndOperator) {
......@@ -1000,10 +1000,9 @@ void QMakeParser::finalizeTest(ushort *&tokPtr)
flushScopes(tokPtr);
putLineMarker(tokPtr);
putOperator(tokPtr);
if (m_invert) {
if (m_invert & 1)
putTok(tokPtr, TokNot);
m_invert = false;
}
m_invert = 0;
m_state = StCond;
m_canElse = true;
}
......@@ -1014,7 +1013,7 @@ void QMakeParser::bogusTest(ushort *&tokPtr, const QString &msg)
parseError(msg);
flushScopes(tokPtr);
m_operator = NoOperator;
m_invert = false;
m_invert = 0;
m_state = StCond;
m_canElse = true;
}
......
......@@ -172,7 +172,7 @@ private:
int m_markLine; // Put marker for this line
bool m_inError; // Current line had a parsing error; suppress followup error messages
bool m_canElse; // Conditionals met on previous line, but no scope was opened
bool m_invert; // Pending conditional is negated
int m_invert; // Pending conditional is negated
enum { NoOperator, AndOperator, OrOperator } m_operator; // Pending conditional is ORed/ANDed
QString m_tmp; // Temporary for efficient toQString
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment