From d83111a012bd0c23d0fd261d4ac80d9948ebf554 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Sat, 18 Jan 2025 11:40:15 +0100 Subject: [PATCH] Add tests for #10561, #10662 --- test/testcondition.cpp | 15 +++++++++++++++ test/testtokenize.cpp | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index c36a9f876d9..3bcaab2c1af 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -4723,6 +4723,21 @@ class TestCondition : public TestFixture { " return 0;\n" "}"); ASSERT_EQUALS("", errout_str()); + + check("int g();\n" // #10561 + "bool h();\n" + "int f() {\n" + " bool b = false;\n" + " try {\n" + " switch (g()) {\n" + " default:\n" + " b = h();\n" + " }\n" + " }\n" + " catch (...) {}\n" + " return b ? 1 : 0;\n" + "}"); + ASSERT_EQUALS("", errout_str()); } void alwaysTrueSymbolic() diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7e049fc4f68..985f0c216b9 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3773,7 +3773,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("unsigned int ( * f ) ( ) ;", tokenizeAndStringify("unsigned int (*f)();")); ASSERT_EQUALS("unsigned int * ( * f ) ( ) ;", tokenizeAndStringify("unsigned int * (*f)();")); ASSERT_EQUALS("void ( * f [ 2 ] ) ( ) ;", tokenizeAndStringify("void (*f[2])();")); - ASSERT_EQUALS("void ( * f [ 2 ] ) ( void ) ;", tokenizeAndStringify("typedef void func_t(void); func_t *f[2];")); + ASSERT_EQUALS("void ( * f [ 2 ] ) ( void ) ;", tokenizeAndStringify("typedef void func_t(void); func_t *f[2];")); // #10581 } void simplifyFunctionPointers2() { @@ -6431,6 +6431,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("sS(new::=", testAst("s = ::new (ptr) S();")); // #12552 ASSERT_EQUALS("pdelete::return", testAst("return ::delete p;")); ASSERT_EQUALS("gn--(delete", testAst("delete g(--n);")); + ASSERT_EQUALS("bdeletep1*p0*,deletep0*p1*,:?*return", testAst("return *(b ? (delete *p1, *p0) : (delete *p0, *p1));")); // #10662 // placement new ASSERT_EQUALS("X12,3,(new ab,c,", testAst("new (a,b,c) X(1,2,3);"));