Skip to content

Commit f47acb0

Browse files
authored
fix #14058: FP incorrectStringBooleanError (std::string_view literal not recognized) (danmar#7795)
1 parent e6e045f commit f47acb0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/checkstring.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ void CheckString::checkIncorrectStringCompare()
318318
}
319319
}
320320
} else if (Token::Match(tok, "%str%|%char%") &&
321+
!Token::Match(tok->next(), "%name%") &&
321322
isUsedAsBool(tok, *mSettings) &&
322323
!isMacroUsage(tok))
323324
incorrectStringBooleanError(tok, tok->str());

test/teststring.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,13 @@ class TestString : public TestFixture {
823823
" if (strequ(p, \"ALL\")) {}\n"
824824
"}\n");
825825
ASSERT_EQUALS("", errout_str());
826+
827+
check("void f(std::string_view);\n"
828+
"void f(bool);\n"
829+
"void g() {\n"
830+
" f(\"\"sv);\n"
831+
"}\n");
832+
ASSERT_EQUALS("", errout_str());
826833
}
827834

828835
void deadStrcmp() {

0 commit comments

Comments
 (0)