parent
b60b374f9c
commit
285ef96b5b
|
@ -8277,7 +8277,8 @@ void Tokenizer::reportUnknownMacros() const
|
|||
|
||||
// String concatenation with unknown macros
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "%str% %name% (") && Token::Match(tok->linkAt(2), ") %str%")) {
|
||||
if ((Token::Match(tok, "%str% %name% (") && Token::Match(tok->linkAt(2), ") %str%")) ||
|
||||
(Token::Match(tok, "%str% %name% %str%") && !(startsWith(tok->strAt(1), "PRI") || startsWith(tok->strAt(1), "SCN")))) { // TODO: implement macros in std.cfg
|
||||
if (tok->next()->isKeyword())
|
||||
continue;
|
||||
unknownMacroError(tok->next());
|
||||
|
|
|
@ -6899,6 +6899,11 @@ private:
|
|||
"void f(float a) {\n"
|
||||
"S s = (S){ .i = (int)a };\n"
|
||||
"}\n", /*expand*/ true, Platform::Type::Native, "test.c"));
|
||||
|
||||
ASSERT_THROW(tokenizeAndStringify("std::string g();\n"
|
||||
"std::string f() {\n"
|
||||
" return std::string{ g() + \"abc\" MACRO \"def\" };\n"
|
||||
"}\n", /*expand*/ true, Platform::Type::Native, "test.cpp"), InternalError);
|
||||
}
|
||||
|
||||
void findGarbageCode() { // Test Tokenizer::findGarbageCode()
|
||||
|
|
|
@ -3530,10 +3530,10 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
checkUninitVar("void f() {\n" // Don't crash
|
||||
ASSERT_THROW(checkUninitVar("void f() {\n" // Don't crash
|
||||
" int a;\n"
|
||||
" dostuff(\"ab\" cd \"ef\", x?a:z);\n" // <- No AST is created for ?:
|
||||
"}");
|
||||
" dostuff(\"ab\" cd \"ef\", x?a:z);\n" // <- No AST is created for ?
|
||||
"}"), InternalError);
|
||||
|
||||
// Unknown => bail out..
|
||||
checkUninitVar("void f(int x) {\n"
|
||||
|
@ -3652,10 +3652,10 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
valueFlowUninit("void f() {\n" // Don't crash
|
||||
ASSERT_THROW(valueFlowUninit("void f() {\n" // Don't crash
|
||||
" int a;\n"
|
||||
" dostuff(\"ab\" cd \"ef\", x?a:z);\n" // <- No AST is created for ?:
|
||||
"}");
|
||||
" dostuff(\"ab\" cd \"ef\", x?a:z);\n" // <- No AST is created for ?
|
||||
"}"), InternalError);
|
||||
|
||||
// Unknown => bail out..
|
||||
valueFlowUninit("void f(int x) {\n"
|
||||
|
|
Loading…
Reference in New Issue