Skip to content

Commit

Permalink
Update testother.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Apr 17, 2024
1 parent 320381f commit 26722c2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ class TestOther : public TestFixture {
}

void varScope40() {
checkP("#define NUM (-999.9)\n"
checkP("#define NUM (-999.9)\n" // #8862
"double f(int i) {\n"
" double a = NUM;\n"
" double b = -NUM;\n"
Expand All @@ -1732,6 +1732,19 @@ class TestOther : public TestFixture {
"[test.cpp:4]: (style) The scope of the variable 'b' can be reduced.\n"
"[test.cpp:5]: (style) The scope of the variable 'c' can be reduced.\n",
errout_str());

check("struct S { int a; };\n" // #12618
"int f(const S* s, int i) {\n"
" int x = s->a;\n"
" const int b[] = { 1, 2, 3 };\n"
" int y = b[1];\n"
" if (i)\n"
" return x + y;\n"
" return 0;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (style) The scope of the variable 'x' can be reduced.\n"
"[test.cpp:5]: (style) The scope of the variable 'y' can be reduced.\n",
errout_str());
}

#define checkOldStylePointerCast(code) checkOldStylePointerCast_(code, __FILE__, __LINE__)
Expand Down

0 comments on commit 26722c2

Please sign in to comment.