Skip to content

Commit 158238a

Browse files
committed
add testcase for #7179 (see bebf8cc )
1 parent febe1c9 commit 158238a

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/testunusedvar.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class TestUnusedVar : public TestFixture {
4747
TEST_CASE(structmember_extern); // No false positives for extern structs
4848
TEST_CASE(structmember10);
4949
TEST_CASE(structmember11); // #4168 - initialization with {} / passed by address to unknown function
50+
TEST_CASE(structmember12); // #7179 - FP unused structmember
5051

5152
TEST_CASE(localvar1);
5253
TEST_CASE(localvar2);
@@ -392,6 +393,26 @@ class TestUnusedVar : public TestFixture {
392393
TODO_ASSERT_EQUALS("abc::x is not used", "", errout.str());
393394
}
394395

396+
void structmember12() { // #7179
397+
checkStructMemberUsage("#include <stdio.h>\n"
398+
"struct\n"
399+
"{\n"
400+
" union\n"
401+
" {\n"
402+
" struct\n"
403+
" {\n"
404+
" int a;\n"
405+
" } struct1;\n"
406+
" };\n"
407+
"} var = {0};\n"
408+
"int main(int argc, char *argv[])\n"
409+
"{\n"
410+
" printf(\"var.struct1.a = %d\n\", var.struct1.a);\n"
411+
" return 1;\n"
412+
"}\n");
413+
ASSERT_EQUALS("", errout.str());
414+
}
415+
395416
void structmember_extern() {
396417
// extern struct => no false positive
397418
checkStructMemberUsage("extern struct AB\n"

0 commit comments

Comments
 (0)