Skip to content

Commit

Permalink
add nested switch statement test
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne committed Sep 17, 2024
1 parent d323bc6 commit 16b6baf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class TestFunctions : public TestFixture {
TEST_CASE(checkMissingReturn2); // #11798
TEST_CASE(checkMissingReturn3);
TEST_CASE(checkMissingReturn4);
TEST_CASE(checkMissingReturn5);

// std::move for locar variable
TEST_CASE(returnLocalStdMove1);
Expand Down Expand Up @@ -1820,6 +1821,30 @@ class TestFunctions : public TestFixture {
ASSERT_EQUALS("[test.cpp:7]: (error) Found an exit path from function with non-void return type that has missing return statement\n", errout_str());
}

void checkMissingReturn5() {
check("enum Enum {\n"
" A,\n"
" B,\n"
" C,\n"
"};\n"
"int f(Enum e, bool b) {\n"
" switch (e) {\n"
" case A:\n"
" return 1;\n"
" case B:\n"
" return 2;\n"
" case C:\n"
" switch (b) {\n"
" case true:\n"
" return 3;\n"
" case false:\n"
" return 4;\n"
" }\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

// NRVO check
void returnLocalStdMove1() {
check("struct A{}; A f() { A var; return std::move(var); }");
Expand Down

0 comments on commit 16b6baf

Please sign in to comment.