Reverted 107b3b44
. Write syntax error for 'if MACRO()'. We can't know if MACRO() is supposed to be used in the condition or if it is some annotation that should be removed. Ticket #4171
This commit is contained in:
parent
e3bbcf501f
commit
4c1abde48e
|
@ -1592,22 +1592,8 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
// 'for each ( )' -> 'for ( )'
|
// 'for each ( )' -> 'for ( )'
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
else {
|
else {
|
||||||
// locate the ')' parenthesis (the Token::link is not set yet)
|
syntaxError(tok);
|
||||||
// Then replace 'if MACRO(X)' with 'if (MACRO(X))'
|
return false;
|
||||||
unsigned int parlevel = 0;
|
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
|
|
||||||
if (tok2->str() == "(")
|
|
||||||
++parlevel;
|
|
||||||
else if (tok2->str() == ")") {
|
|
||||||
if (parlevel == 1) {
|
|
||||||
tok->insertToken("(");
|
|
||||||
tok2->insertToken(")");
|
|
||||||
}
|
|
||||||
if (parlevel <= 1)
|
|
||||||
break;
|
|
||||||
--parlevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -709,10 +709,10 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void wrong_syntax_if_macro() {
|
void wrong_syntax_if_macro() {
|
||||||
// #2518 and #4171
|
// #2518
|
||||||
const char code[] = "void f() { if MACRO() { } }";
|
const std::string code("void f() { if MACRO(); }");
|
||||||
ASSERT_EQUALS("void f ( ) { if ( MACRO ( ) ) { } }", tokenizeAndStringify(code, false));
|
tokenizeAndStringify(code.c_str(), false);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void garbageCode() {
|
void garbageCode() {
|
||||||
|
|
Loading…
Reference in New Issue