Skip to content

Commit 54f724e

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

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines 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

Lines 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)