Skip to content

Commit c4179a0

Browse files
committed
Debug enumFitsInType
1 parent ba3afac commit c4179a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cpp/misra/src/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ predicate compoundAssignmentUsesUnscopedUnfixedEnum(
107107
}
108108

109109
predicate assignmentSourceIsUnscopedUnfixedEnum(AssignExpr assign) {
110-
isUnscopedEnumWithoutFixedUnderlyingType(assign.getRValue().getUnderlyingType())
110+
isUnscopedEnumWithoutFixedUnderlyingType(assign.getRValue().getUnderlyingType()) and
111+
not enumFitsInType(assign.getRValue().getUnderlyingType(), assign.getLValue().getUnderlyingType())
111112
}
112113

113114
/**
@@ -161,6 +162,8 @@ predicate enumFitsInType(Enum e, IntegralType type) {
161162
or
162163
signed = false and type.isUnsigned()
163164
)
165+
or
166+
type.getSize() * 8 > minBits
164167
)
165168
}
166169

0 commit comments

Comments
 (0)