Skip to content

Commit 9619ec0

Browse files
mbaludaCopilot
andcommitted
Preserve DIR-4-6 category mismatch diagnostics
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8ca8aaa commit 9619ec0

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎c/misra/src/codingstandards/c/misra/PlainNumericalTypes.qll‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ predicate integerProblems(Element element, string message) {
119119
or
120120
exists(CTypedefType type | type = element and forbiddenAlias(type, _) |
121121
if type.getName() instanceof SizedTypeName
122-
then message = "The typedef type '" + type.getName() + "' does not have its indicated size."
122+
then
123+
if type.getName().(SizedTypeName).isComplex()
124+
then message = "The typedef type '" + type.getName() + "' is not a complex type."
125+
else message = "The typedef type '" + type.getName() + "' does not have its indicated size."
123126
else
124127
message = "The type '" + type.getName() + "' is not an alias to a fixed-width integer type."
125128
)

‎c/misra/test/rules/DIR-4-6/integer-only/PlainIntegerTypeUsedOverExplicitTypedef.expected‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
| test.c:42:13:42:15 | ll1 | The type 'long long' is not a fixed-width integer type. |
1616
| test.c:43:20:43:22 | ll2 | The type 'signed long long' is not a fixed-width integer type. |
1717
| test.c:44:22:44:24 | ll3 | The type 'unsigned long long' is not a fixed-width integer type. |
18+
| test.c:54:15:54:24 | cfloat32_t | The typedef type 'cfloat32_t' is not a complex type. |
19+
| test.c:55:15:55:24 | cfloat16_t | The typedef type 'cfloat16_t' is not a complex type. |

‎c/misra/test/rules/DIR-4-6/integer-only/test.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ int main(int argc, char *argv[]) { // COMPLIANT - main signature exception
4949
float _Complex cf1 = 1.0f; // COMPLIANT - floating-point excluded
5050
return 0;
5151
}
52+
53+
void test_complex_names(void) {
54+
typedef int cfloat32_t; // NON_COMPLIANT - not complex despite matching indicated width
55+
typedef int cfloat16_t; // NON_COMPLIANT - not complex despite mismatched indicated width
56+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
- `DIR-4-6` - `PlainIntegerTypeUsedOverExplicitTypedef.ql`:
22
- The MISRA C:2025 query checks integer types and excludes floating-point declarations and
33
aliases. Earlier editions retain the numerical-type query.
4+
- Integer typedefs with complex-type names report that the type is not complex, rather than an
5+
incorrect size.

0 commit comments

Comments
 (0)