Skip to content

Commit 9fc57bd

Browse files
committed
DIR-4-6: Only flag aliases of built-in numeric types.
1 parent 4e5e05a commit 9fc57bd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

c/misra/src/rules/DIR-4-6/PlainNumericalTypeUsedOverExplicitTypedef.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ predicate forbiddenTypedef(CTypedefType typedef, string message) {
4949
typedef.getName().regexpCapture("u?(int|float)(4|8|16|32|64|128)_t", 2).toInt() and
5050
message = "The typedef type " + typedef.getName() + " does not have its indicated size."
5151
) else (
52-
/* Otherwise, the aliased type itself should have an explicit size in its name. */
53-
not typedef.getBaseType().getName().regexpMatch("u?(int|float)(4|8|16|32|64|128)_t") and
52+
/* Otherwise, if the type is an alias of a built in numeric type it should have an explicit size in its name. */
53+
typedef.getUnspecifiedType() instanceof BuiltInNumericType and
54+
not typedef.getBaseType+().getName().regexpMatch("u?(int|float)(4|8|16|32|64|128)_t") and
5455
message = "The type " + typedef.getName() + " is not an alias to a fixed-width numeric type."
5556
)
5657
)

0 commit comments

Comments
 (0)