From edd86c0b0a9eeb7f3d6e73273186e6ecac85dbeb Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Aug 2021 09:41:26 +0200 Subject: [PATCH] Add regression test for ticket #10374 (#3386) --- test/testother.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index 142c46278..9d84632bf 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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"