From ceb86afc22dc830c5dbd998e4a7f0196c61a8e0f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:11:14 +0200 Subject: [PATCH] Fix #10952 FP constStatement with cast in return (#3986) --- lib/tokenize.cpp | 2 +- test/testincompletestatement.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 199fbb993..d3ae860ea 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3111,7 +3111,7 @@ void Tokenizer::simplifyArrayAccessSyntax() void Tokenizer::simplifyParameterVoid() { for (Token* tok = list.front(); tok; tok = tok->next()) { - if (Token::Match(tok, "%name% ( void )") && !Token::Match(tok, "sizeof|decltype|typeof")) { + if (Token::Match(tok, "%name% ( void )") && !Token::Match(tok, "sizeof|decltype|typeof|return")) { tok->next()->deleteNext(); tok->next()->setRemovedVoidParameter(true); } diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 8f6bc0e0c..eefe58854 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -372,6 +372,12 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + check("void g();\n" // #10952 + "bool f() {\n" + " return (void)g(), false;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + check("void f(int a, int b, int c, int d) {\n" " Eigen::Vector4d V;\n" " V << a, b, c, d;\n"