diff --git a/lib/astutils.cpp b/lib/astutils.cpp index c1fc6fcd9..3b71f9f7f 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1748,7 +1748,7 @@ bool isReturnScope(const Token* const endToken, const Library* library, const To if (!functionScope && Token::simpleMatch(prev->link()->previous(), ") {") && Token::simpleMatch(prev->link()->linkAt(-1)->previous(), "switch (") && !Token::findsimplematch(prev->link(), "break", prev)) { - return true; + return isReturnScope(prev, library, unknownFunc, functionScope); } if (isEscaped(prev->link()->astTop(), functionScope, library)) return true; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 74e345dea..3452076c1 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3800,6 +3800,15 @@ private: " do {} while (i++ == 0);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #10582 + check("static void fun(message_t *message) {\n" + " if (message->length >= 1) {\n" + " switch (data[0]) {}\n" + " }\n" + " uint8_t d0 = message->length > 0 ? data[0] : 0xff;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueSymbolic()