From 4c1abde48e88463ee314799b30a6c1b9fc76e533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 6 Oct 2012 19:12:39 +0200 Subject: [PATCH] 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 --- lib/tokenize.cpp | 18 ++---------------- test/testtokenize.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 077ef5bdd..312f669de 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1592,22 +1592,8 @@ bool Tokenizer::tokenize(std::istream &code, // 'for each ( )' -> 'for ( )' tok->deleteNext(); else { - // locate the ')' parenthesis (the Token::link is not set yet) - // Then replace 'if MACRO(X)' with 'if (MACRO(X))' - 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; - } - } + syntaxError(tok); + return false; } } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 542b59907..7c43e317c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -709,10 +709,10 @@ private: } void wrong_syntax_if_macro() { - // #2518 and #4171 - const char code[] = "void f() { if MACRO() { } }"; - ASSERT_EQUALS("void f ( ) { if ( MACRO ( ) ) { } }", tokenizeAndStringify(code, false)); - ASSERT_EQUALS("", errout.str()); + // #2518 + const std::string code("void f() { if MACRO(); }"); + tokenizeAndStringify(code.c_str(), false); + ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str()); } void garbageCode() {