diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1167befdc83..735d84b6fa9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8729,10 +8729,16 @@ void Tokenizer::findGarbageCode() const if (Token::Match(tok, "%num%|%bool%|%char%|%str% %num%|%bool%|%char%|%str%") && !Token::Match(tok, "%str% %str%")) syntaxError(tok); if (Token::Match(tok, "%num%|%bool%|%char%|%str% {|(")) { - if (tok->strAt(1) == "(") + if (tok->strAt(1) == "(") { + if (tok->isExpandedMacro() && mSettings.userDefines.empty()) { + throw InternalError(tok, "literal used as function. Macro '" + tok->getMacroName() + + "' expands to '" + tok->str() + +"'. Use -D" + tok->getMacroName() + + "=... to specify a value, or -U" + tok->getMacroName() + + " to undefine it.", InternalError::UNKNOWN_MACRO); + } syntaxError(tok); - else if (!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) && - !(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires"))) + } else if (!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) && + !(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires"))) syntaxError(tok); } if (Token::Match(tok, "( ) %num%|%bool%|%char%|%str%"))