diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 41bea2189..32f885eb2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9154,8 +9154,10 @@ void Tokenizer::findGarbageCode() const syntaxError(list.back()); if (list.back()->str() == ")" && !Token::Match(list.back()->link()->previous(), "%name% (")) syntaxError(list.back()); - if (Token::Match(list.back(), "void|char|short|int|long|float|double|const|volatile|static|inline|struct|class|enum|union|template|sizeof|case|break|continue|typedef")) - syntaxError(list.back()); + for (const Token *end = list.back(); end && end->isName(); end = end->previous()) { + if (Token::Match(end, "void|char|short|int|long|float|double|const|volatile|static|inline|struct|class|enum|union|template|sizeof|case|break|continue|typedef")) + syntaxError(list.back()); + } if ((list.back()->str()==")" || list.back()->str()=="}") && list.back()->previous() && list.back()->previous()->isControlFlowKeyword()) syntaxError(list.back()->previous()); diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index ace4f0087..0b624f948 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -1638,6 +1638,7 @@ private: ASSERT_THROW(checkCode("int"), InternalError); ASSERT_THROW(checkCode("struct A :\n"), InternalError); // #2591 ASSERT_THROW(checkCode("{} const const\n"), InternalError); // #2637 + ASSERT_THROW(checkCode("re2c: error: line 14, column 4: can only difference char sets"), InternalError); // ASSERT_THROW( , InternalError) }