diff --git a/cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql b/cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql index 82b7f146554f..16ac18b87cce 100644 --- a/cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql +++ b/cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql @@ -12,7 +12,11 @@ import cpp predicate allowedTypedefs(TypedefType t) { - t.getName() = ["I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32"] + t.getName() = + [ + "I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32", "int64_t", "uint64_t", + "int32_t", "uint32_t", "int16_t", "uint16_t", "int8_t", "uint8_t" + ] } /** @@ -46,6 +50,8 @@ from Declaration d, Type usedType where usedType = getAUsedType*(getAnImmediateUsedType(d)) and problematic(usedType) and + // Allow uses of boolean types where defined by the language. + not usedType instanceof BoolType and // Ignore violations for which we do not have a valid location. not d.getLocation() instanceof UnknownLocation select d, diff --git a/cpp/ql/src/change-notes/2025-03-11-basic-int-types.md b/cpp/ql/src/change-notes/2025-03-11-basic-int-types.md new file mode 100644 index 000000000000..7d3bd4b82339 --- /dev/null +++ b/cpp/ql/src/change-notes/2025-03-11-basic-int-types.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* The query "Use of basic integral type" (`cpp/jpl-c/basic-int-types`) no longer produces alerts for the standard fixed width integer types (`int8_t`, `uint8_t`, etc.), and the `_Bool` and `bool` types. \ No newline at end of file diff --git a/cpp/ql/test/query-tests/JPL_C/LOC-3/Rule 17/BasicIntTypes.expected b/cpp/ql/test/query-tests/JPL_C/LOC-3/Rule 17/BasicIntTypes.expected index 0664ca9e3698..58facbeac8e2 100644 --- a/cpp/ql/test/query-tests/JPL_C/LOC-3/Rule 17/BasicIntTypes.expected +++ b/cpp/ql/test/query-tests/JPL_C/LOC-3/Rule 17/BasicIntTypes.expected @@ -1,3 +1 @@ | test.c:6:26:6:26 | x | x uses the basic integral type unsigned char rather than a typedef with size and signedness. | -| test.c:7:20:7:20 | x | x uses the basic integral type unsigned char rather than a typedef with size and signedness. | -| test.c:10:16:10:20 | test7 | test7 uses the basic integral type unsigned char rather than a typedef with size and signedness. |