Skip to content

Commit

Permalink
Add tests for #10561, #10662
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 18, 2025
1 parent 8f42596 commit d83111a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);"));
Expand Down

0 comments on commit d83111a

Please sign in to comment.