File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -8095,8 +8095,12 @@ void Tokenizer::findGarbageCode() const
80958095 if (!isCPP () || mSettings ->standards .cpp < Standards::CPP20 || !Token::Match (tok->previous (), " %name% : %num% =" ))
80968096 syntaxError (tok, tok->next ()->str () + " " + tok->strAt (2 ));
80978097 }
8098- else if (Token::simpleMatch (tok, " ) return" ) && !Token::Match (tok->link ()->previous (), " if|while|for (" ))
8099- syntaxError (tok);
8098+ else if (Token::simpleMatch (tok, " ) return" ) && !Token::Match (tok->link ()->previous (), " if|while|for (" )) {
8099+ if (tok->link ()->previous () && tok->link ()->previous ()->isUpperCaseName ())
8100+ unknownMacroError (tok->link ()->previous ());
8101+ else
8102+ syntaxError (tok);
8103+ }
81008104
81018105 if (tok->isControlFlowKeyword () && Token::Match (tok, " if|while|for|switch" )) { // if|while|for|switch (EXPR) { ... }
81028106 if (tok->previous () && !Token::Match (tok->previous (), " %name%|:|;|{|}|)" )) {
Original file line number Diff line number Diff line change @@ -6834,6 +6834,9 @@ class TestTokenizer : public TestFixture {
68346834 ASSERT_THROW_EQUALS (tokenizeAndStringify (" enum : 3 { };" ), InternalError, " syntax error: Unexpected token '3'" );
68356835
68366836 ASSERT_THROW_EQUALS (tokenizeAndStringify (" int a() { b((c)return 0) }" ), InternalError, " syntax error" );
6837+ ASSERT_THROW_EQUALS (tokenizeAndStringify (" int f() { MACRO(x) return 0; }" ),
6838+ InternalError,
6839+ " There is an unknown macro here somewhere. Configuration is required. If MACRO is a macro then please configure it." );
68376840 }
68386841
68396842
You can’t perform that action at this time.
0 commit comments