Skip to content

Commit 1f6b8f9

Browse files
committed
Fix queries and tests that reference anonymous structs and unions
1 parent cdbb9b9 commit 1f6b8f9

File tree

11 files changed

+15
-16
lines changed

11 files changed

+15
-16
lines changed

c/cert/src/rules/EXP39-C/DoNotAccessVariableViaPointerOfIncompatibleType.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ Type compatibleTypes(Type type) {
163163
(
164164
type.stripType() instanceof Struct and
165165
type.getUnspecifiedType() = result.getUnspecifiedType() and
166-
not type.getName() = "struct <unnamed>" and
167-
not result.getName() = "struct <unnamed>"
166+
not type.(Struct).isAnonymous() and
167+
not result.(Struct).isAnonymous()
168168
or
169169
not type.stripType() instanceof Struct and
170170
(

c/cert/test/rules/EXP39-C/DoNotAccessVariableViaPointerOfIncompatibleType.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ subpaths
5353
| test.c:13:17:13:19 | & ... | test.c:13:17:13:19 | & ... | test.c:13:17:13:19 | & ... | Cast from short[2] to short[4] results in an incompatible pointer base type. |
5454
| test.c:19:18:19:20 | & ... | test.c:19:18:19:20 | & ... | test.c:19:18:19:20 | & ... | Cast from char to signed char results in an incompatible pointer base type. |
5555
| test.c:30:19:30:21 | & ... | test.c:30:19:30:21 | & ... | test.c:30:19:30:21 | & ... | Cast from int to unsigned int results in an incompatible pointer base type. |
56-
| test.c:47:8:47:9 | s2 | test.c:47:8:47:9 | s2 | test.c:47:8:47:9 | s2 | Cast from struct <unnamed> to struct <unnamed> results in an incompatible pointer base type. |
57-
| test.c:49:8:49:9 | s3 | test.c:49:8:49:9 | s3 | test.c:49:8:49:9 | s3 | Cast from S1 to struct <unnamed> results in an incompatible pointer base type. |
58-
| test.c:50:8:50:9 | s1 | test.c:50:8:50:9 | s1 | test.c:50:8:50:9 | s1 | Cast from struct <unnamed> to S1 results in an incompatible pointer base type. |
56+
| test.c:47:8:47:9 | s2 | test.c:47:8:47:9 | s2 | test.c:47:8:47:9 | s2 | Cast from (unnamed class/struct/union) to (unnamed class/struct/union) results in an incompatible pointer base type. |
57+
| test.c:49:8:49:9 | s3 | test.c:49:8:49:9 | s3 | test.c:49:8:49:9 | s3 | Cast from S1 to (unnamed class/struct/union) results in an incompatible pointer base type. |
58+
| test.c:50:8:50:9 | s1 | test.c:50:8:50:9 | s1 | test.c:50:8:50:9 | s1 | Cast from (unnamed class/struct/union) to S1 results in an incompatible pointer base type. |
5959
| test.c:68:41:68:41 | v | test.c:72:13:72:15 | & ... | test.c:68:41:68:41 | v | Cast from float to int results in an incompatible pointer base type. |
6060
| test.c:99:3:99:4 | s3 | test.c:98:40:98:41 | s2 | test.c:99:3:99:4 | s3 | Cast from S2 to S3 results in an incompatible pointer base type. |

c/common/test/rules/informationleakageacrossboundaries/InformationLeakageAcrossBoundaries.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| interprocedural.c:104:9:104:9 | p | 'p' may leak information from {x (interprocedural.c:7), y (interprocedural.c:8)}. Path: p (interprocedural.c:104) --> overwrite_after_leak(...) (interprocedural.c:96) --> p (interprocedural.c:97) |
66
| multilayer.c:16:10:16:10 | s | 's' may leak information from {b (multilayer.c:12)}. Path: s (multilayer.c:16) --> & ... (multilayer.c:18) |
77
| multilayer.c:29:10:29:10 | s | 's' may leak information from {b (multilayer.c:12), x (multilayer.c:7)}. Path: s (multilayer.c:29) --> & ... (multilayer.c:30) |
8-
| multilayer.c:34:8:34:8 | s | 's' may leak information from {struct <unnamed> (multilayer.c:6)}. Path: s (multilayer.c:34) --> & ... (multilayer.c:35) |
8+
| multilayer.c:34:8:34:8 | s | 's' may leak information from {(unnamed class/struct/union) (multilayer.c:6)}. Path: s (multilayer.c:34) --> & ... (multilayer.c:35) |
99
| test.c:12:12:12:12 | s | 's' may leak information from {y (test.c:8)}. Path: s (test.c:12) --> & ... (test.c:14) |
1010
| test.c:18:12:18:12 | s | 's' may leak information from {x (test.c:7)}. Path: s (test.c:18) --> & ... (test.c:20) |
1111
| test.c:24:12:24:12 | s | 's' may leak information from {x (test.c:7), y (test.c:8)}. Path: s (test.c:24) --> & ... (test.c:25) |

c/common/test/rules/unusedtypedeclarations/UnusedTypeDeclarations.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
| test.c:4:8:4:8 | A | Type declaration A is not used. |
33
| test.c:7:18:7:18 | D | Type declaration D is not used. |
44
| test.c:28:11:28:11 | R | Type declaration R is not used. |
5-
| test.c:41:12:41:12 | struct <unnamed> | Type declaration struct <unnamed> is not used. |
5+
| test.c:41:12:41:12 | (unnamed class/struct/union) | Type declaration (unnamed class/struct/union) is not used. |

c/common/test/rules/useinitializerbracestomatchaggregatetypestructure/UseInitializerBracesToMatchAggregateTypeStructure.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
| test.c:35:32:35:35 | {...} | Missing braces on aggregate literal of type int[2]$@ which is assigned to index 2 in $@. | file://:0:0:0:0 | int[2] | int[2] | test.c:35:18:35:42 | {...} | array of type int[4][2] |
44
| test.c:35:38:35:41 | {...} | Missing braces on aggregate literal of type int[2]$@ which is assigned to index 3 in $@. | file://:0:0:0:0 | int[2] | int[2] | test.c:35:18:35:42 | {...} | array of type int[4][2] |
55
| test.c:41:34:41:34 | {...} | Missing braces on aggregate literal of type int[2]$@ which is assigned to index 1 in $@. | file://:0:0:0:0 | int[2] | int[2] | test.c:41:18:41:35 | {...} | array of type int[2][2] |
6-
| test.c:47:26:47:29 | {...} | Missing braces on aggregate literal of type $@ which is assigned to field $@. | test.c:4:10:4:10 | struct <unnamed> | struct <unnamed> | test.c:7:5:7:8 | m_s1 | m_s1 |
7-
| test.c:47:26:47:29 | {...} | Missing braces on aggregate literal of type $@ which is assigned to field $@. | test.c:11:10:11:10 | struct <unnamed> | struct <unnamed> | test.c:7:5:7:8 | m_s1 | m_s1 |
6+
| test.c:47:26:47:29 | {...} | Missing braces on aggregate literal of type $@ which is assigned to field $@. | test.c:4:10:4:10 | (unnamed class/struct/union) | (unnamed class/struct/union) | test.c:7:5:7:8 | m_s1 | m_s1 |
7+
| test.c:47:26:47:29 | {...} | Missing braces on aggregate literal of type $@ which is assigned to field $@. | test.c:11:10:11:10 | (unnamed class/struct/union) | (unnamed class/struct/union) | test.c:7:5:7:8 | m_s1 | m_s1 |

c/misra/src/rules/RULE-2-4/UnusedTagDeclaration.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ from UserType s
2020
where
2121
not isExcluded(s, DeadCodePackage::unusedTagDeclarationQuery()) and
2222
// ignore structs without a tag name
23-
not s.getName() = "struct <unnamed>" and
23+
not s.isAnonymous() and
2424
// typedefs do not have a "tag" name, so this rule does not apply to them
2525
not s instanceof TypedefType and
2626
// Not mentioned anywhere

c/misra/src/rules/RULE-5-7/TagNameNotUnique.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ where
2222
not isExcluded(s2, Declarations3Package::tagNameNotUniqueQuery()) and
2323
not s = s2 and
2424
s.getName() = s2.getName() and
25-
not s.getName() = "struct <unnamed>" and
26-
not s.getName() = "union <unnamed>" and
25+
not s.isAnonymous() and
2726
not s.getName() = s2.(TypedefType).getBaseType().toString()
2827
select s, "Tag name is nonunique compared to $@.", s2, s2.getName()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| test.c:2:9:2:9 | union <unnamed> | Use of banned 'union' keyword. |
1+
| test.c:2:9:2:9 | (unnamed class/struct/union) | Use of banned 'union' keyword. |

cpp/autosar/src/rules/M8-0-1/MultipleGlobalOrMemberDeclarators.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class NonLocalUserDeclaration extends Declaration {
4646
not this.(Parameter).getFunction().isCompilerGenerated() and
4747
not this.isInMacroExpansion() and
4848
not exists(Struct s, TypedefType t |
49-
s.getName() = "struct <unnamed>" and
49+
s.isAnonymous() and
5050
t.getBaseType() = s and
5151
this = s.getAMemberVariable()
5252
)

cpp/common/test/rules/unusedtypedeclarations/UnusedTypeDeclarations.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
| test.cpp:6:7:6:7 | B | Type declaration B is not used. |
44
| test.cpp:13:11:13:11 | D | Type declaration D is not used. |
55
| test.cpp:77:11:77:11 | R | Type declaration R is not used. |
6-
| test.cpp:90:12:90:12 | struct <unnamed> | Type declaration struct <unnamed> is not used. |
6+
| test.cpp:90:12:90:12 | (unnamed class/struct/union) | Type declaration (unnamed class/struct/union) is not used. |
77
| test.cpp:111:29:111:30 | AA | Type declaration AA is not used. |

cpp/common/test/rules/useinitializerbracestomatchaggregatetypestructure/UseInitializerBracesToMatchAggregateTypeStructure.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
| test.cpp:41:22:41:25 | {...} | Missing braces on aggregate literal of type int[2]$@ which is assigned to index 1 in $@. | file://:0:0:0:0 | int[2] | int[2] | test.cpp:41:16:41:38 | {...} | array of type int[4][2] |
33
| test.cpp:41:28:41:31 | {...} | Missing braces on aggregate literal of type int[2]$@ which is assigned to index 2 in $@. | file://:0:0:0:0 | int[2] | int[2] | test.cpp:41:16:41:38 | {...} | array of type int[4][2] |
44
| test.cpp:41:34:41:37 | {...} | Missing braces on aggregate literal of type int[2]$@ which is assigned to index 3 in $@. | file://:0:0:0:0 | int[2] | int[2] | test.cpp:41:16:41:38 | {...} | array of type int[4][2] |
5-
| test.cpp:48:15:48:18 | {...} | Missing braces on aggregate literal of type $@ which is assigned to field $@. | test.cpp:6:10:6:10 | struct <unnamed> | struct <unnamed> | test.cpp:9:5:9:8 | m_s1 | m_s1 |
5+
| test.cpp:48:15:48:18 | {...} | Missing braces on aggregate literal of type $@ which is assigned to field $@. | test.cpp:6:10:6:10 | (unnamed class/struct/union) | (unnamed class/struct/union) | test.cpp:9:5:9:8 | m_s1 | m_s1 |

0 commit comments

Comments
 (0)