diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 5bb96a8cd4d..4315ccf4406 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1521,6 +1521,8 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars() continue; if (Token::Match(tok->next(), "&|&&|* *| *| )|,|%var%|const")) continue; + if (Token::Match(tok->previous(), "%str%")) + continue; // Very likely a typelist if (Token::Match(tok->tokAt(-2), "%type% ,") || Token::Match(tok->next(), ", %type%")) continue; diff --git a/test/cfg/std.c b/test/cfg/std.c index 32b6fe61534..b96f1bf8317 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -5036,7 +5036,6 @@ void invalidPrintfArgType_printf(void) // #7016 uint8_t n = 7; // TODO cppcheck-suppress invalidPrintfArgType_uint - // cppcheck-suppress valueFlowBailoutIncompleteVar printf("%" PRIi16 "\n", n); } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 71578810017..8762c5141d6 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -9066,8 +9066,8 @@ class TestValueFlow : public TestFixture { ASSERT_EQUALS(false, testValueOfX(code, 5U, 0)); } - void valueFlowBailoutIncompleteVar() { // #12526 - bailout( + void valueFlowBailoutIncompleteVar() { + bailout( // #12526 "int f1() {\n" " return VALUE_1;\n" "}\n" @@ -9080,6 +9080,13 @@ class TestValueFlow : public TestFixture { "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable VALUE_1\n" "[test.cpp:6]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable VALUE_2\n", errout_str()); + + bailout( + "std::string_view f() {\n" + " return \"abc\"sv;\n" + "}\n" + ); + ASSERT_EQUALS_WITHOUT_LINENUMBERS("", errout_str()); } void valueFlowBailoutNoreturn() { // #13718