Skip to content

Commit ee22687

Browse files
Anton Lindqvistmptre
authored andcommitted
Add tests for unused attribute in multi-name declarations
The unused attribute in declarations with several names now marks the correct variable or struct member.
1 parent 5dac7e9 commit ee22687

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎test/testunusedvar.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,11 @@ class TestUnusedVar : public TestFixture {
20682068
" int i3 __attribute__((unused)) {};\n"
20692069
"};\n");
20702070
ASSERT_EQUALS("", errout_str());
2071+
2072+
checkStructMemberUsage("struct S {\n"
2073+
" int a __attribute__((unused)), b;\n"
2074+
"};\n");
2075+
ASSERT_EQUALS("[test.cpp:2:36]: (style) struct member 'S::b' is never used. [unusedStructMember]\n", errout_str());
20712076
}
20722077

20732078
void structmember31() { // #14130
@@ -6015,6 +6020,12 @@ class TestUnusedVar : public TestFixture {
60156020
" char b[1][2] __attribute__((unused));\n"
60166021
"}\n");
60176022
ASSERT_EQUALS("", errout_str());
6023+
6024+
functionVariableUsage("int foo()\n"
6025+
"{\n"
6026+
" int x __attribute__((unused)), y;\n"
6027+
"}\n");
6028+
ASSERT_EQUALS("[test.cpp:3:36]: (style) Unused variable: y [unusedVariable]\n", errout_str());
60186029
}
60196030

60206031
void localvarFunction() {

0 commit comments

Comments
 (0)