Add regression test for ticket #10374 (#3386)

This commit is contained in:
chrchr-github 2021-08-06 09:41:26 +02:00 committed by GitHub
parent b729c4a126
commit edd86c0b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -246,6 +246,7 @@ private:
TEST_CASE(shadowVariables);
TEST_CASE(knownArgument);
TEST_CASE(knownArgumentHiddenVariableExpression);
TEST_CASE(knownArgumentTernaryOperator);
TEST_CASE(checkComparePointers);
TEST_CASE(unusedVariableValueTemplate); // #8994
@ -9287,6 +9288,18 @@ private:
"[test.cpp:7]: (style) Argument '0*x' to function dostuff is always 0. Constant literal calculation disable/hide variable expression 'x'.\n", errout.str());
}
void knownArgumentTernaryOperator() { // #10374
check("void f(bool a, bool b) {\n"
" const T* P = nullptr; \n"
" long N = 0; \n"
" const bool c = foo(); \n"
" bar(P, N); \n"
" if (c ? a : b)\n"
" baz(P, N); \n"
"}");
ASSERT_EQUALS("", errout.str());
}
void checkComparePointers() {
check("int f() {\n"
" const int foo[1] = {0};\n"