Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54f724e

Browse filesBrowse files
committed
Rule 10.4: Resolve typedefs before determining if enums are equal
1 parent b5377b4 commit 54f724e
Copy full SHA for 54f724e

File tree

Expand file treeCollapse file tree

2 files changed

+6
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-1
lines changed

‎c/misra/src/rules/RULE-10-4/OperandsWithMismatchedEssentialTypeCategory.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-10-4/OperandsWithMismatchedEssentialTypeCategory.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ where
3838
// be reported as non-compliant.
3939
leftOpTypeCategory = EssentiallyEnumType() and
4040
rightOpTypeCategory = EssentiallyEnumType() and
41-
not leftOpEssentialType = rightOpEssentialType and
41+
not leftOpEssentialType.getUnspecifiedType() = rightOpEssentialType.getUnspecifiedType() and
4242
message =
4343
"The operands of this operator with usual arithmetic conversions have mismatched essentially Enum types (left operand: "
4444
+ leftOpEssentialType + ", right operand: " + rightOpEssentialType + ")."

‎c/misra/test/rules/RULE-10-4/test.c

Copy file name to clipboardExpand all lines: c/misra/test/rules/RULE-10-4/test.c
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ void testOps() {
3737
enum { G };
3838
s32 + G; // COMPLIANT
3939
c == '\n'; // COMPLIANT
40+
41+
typedef enum { H } E3;
42+
43+
E3 e3a = H;
44+
e3a < H; // COMPLIANT
4045
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.