Skip to content

Commit cca63e4

Browse files
Report ATOMIC_VAR_INIT for all C versions.
1 parent e27e49a commit cca63e4

10 files changed

+20
-25
lines changed

c/misra/src/rules/RULE-1-5/UseOfObsoleteMacroAtomicVarInit.ql

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
import cpp
1717
import codingstandards.c.misra
1818

19-
from MacroInvocation invoke, Compilation c, string flag
19+
from MacroInvocation invoke
2020
where
2121
not isExcluded(invoke, Language4Package::useOfObsoleteMacroAtomicVarInitQuery()) and
22-
invoke.getMacroName() = "ATOMIC_VAR_INIT" and
23-
flag = c.getAnArgument() and
24-
flag.regexpMatch("-std=c1[78]")
22+
invoke.getMacroName() = "ATOMIC_VAR_INIT"
2523
select invoke,
26-
"Usage of macro ATOMIC_VAR_INIT() is considered obsolete for c version '" + flag + "'."
24+
"Usage of macro ATOMIC_VAR_INIT() is declared obscelescent in C18, and discouraged in earlier C versions."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| test.c:13:14:13:14 | 0 | Calling realloc with size zero results in implementation-defined behavior. |
1+
| test.c:11:14:11:14 | 0 | Calling realloc with size zero results in implementation-defined behavior. |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| test.c:40:6:40:7 | f2 | Function f2 does not specify void for no parameters present. |
2-
| test.c:44:5:44:6 | f5 | Function f5 declares parameter in unsupported declaration list. |
1+
| test.c:38:6:38:7 | f2 | Function f2 does not specify void for no parameters present. |
2+
| test.c:42:5:42:6 | f5 | Function f5 declares parameter in unsupported declaration list. |
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| test.c:23:1:23:14 | #define true 3 | Invalid define of boolean standard macro 'true'. |
2-
| test.c:24:1:24:15 | #define false 3 | Invalid define of boolean standard macro 'false'. |
3-
| test.c:25:1:25:18 | #define bool int * | Invalid define of boolean standard macro 'bool'. |
4-
| test.c:26:1:26:11 | #undef true | Invalid undefine of boolean standard macro 'true'. |
5-
| test.c:27:1:27:12 | #undef false | Invalid undefine of boolean standard macro 'false'. |
6-
| test.c:28:1:28:11 | #undef bool | Invalid undefine of boolean standard macro 'bool'. |
1+
| test.c:21:1:21:14 | #define true 3 | Invalid define of boolean standard macro 'true'. |
2+
| test.c:22:1:22:15 | #define false 3 | Invalid define of boolean standard macro 'false'. |
3+
| test.c:23:1:23:18 | #define bool int * | Invalid define of boolean standard macro 'bool'. |
4+
| test.c:24:1:24:11 | #undef true | Invalid undefine of boolean standard macro 'true'. |
5+
| test.c:25:1:25:12 | #undef false | Invalid undefine of boolean standard macro 'false'. |
6+
| test.c:26:1:26:11 | #undef bool | Invalid undefine of boolean standard macro 'bool'. |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| test.c:10:12:10:17 | call to malloc | Use of banned dynamic memory allocation. |
2-
| test.c:13:3:13:9 | call to realloc | Use of banned dynamic memory allocation. |
3-
| test.c:16:3:16:9 | call to realloc | Use of banned dynamic memory allocation. |
1+
| test.c:8:12:8:17 | call to malloc | Use of banned dynamic memory allocation. |
2+
| test.c:11:3:11:9 | call to realloc | Use of banned dynamic memory allocation. |
3+
| test.c:14:3:14:9 | call to realloc | Use of banned dynamic memory allocation. |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| test.c:37:12:37:13 | declaration of g5 | The redeclaration of $@ with internal linkage misses the static specifier. | test.c:36:12:36:13 | definition of g5 | g5 |
1+
| test.c:35:12:35:13 | declaration of g5 | The redeclaration of $@ with internal linkage misses the static specifier. | test.c:34:12:34:13 | definition of g5 | g5 |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| test.c:55:3:55:8 | call to ungetc | Call to banned function ungetc. |
2-
| test.c:58:3:58:7 | call to fread | Call to banned function fread. |
3-
| test.c:60:3:60:8 | call to ungetc | Call to banned function ungetc. |
1+
| test.c:53:3:53:8 | call to ungetc | Call to banned function ungetc. |
2+
| test.c:56:3:56:7 | call to fread | Call to banned function fread. |
3+
| test.c:58:3:58:8 | call to ungetc | Call to banned function ungetc. |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| test.c:30:18:30:36 | ATOMIC_VAR_INIT(value) | Usage of macro ATOMIC_VAR_INIT() is considered obsolete for c version '-std=c17'. |
1+
| test.c:28:18:28:36 | ATOMIC_VAR_INIT(value) | Usage of macro ATOMIC_VAR_INIT() is declared obscelescent in C18, and discouraged in earlier C versions. |

c/misra/test/rules/RULE-1-5/options

Lines changed: 0 additions & 1 deletion
This file was deleted.

c/misra/test/rules/RULE-1-5/test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Compiled with -std=c17
2-
31
#include "stdatomic.h"
42
#include "stdbool.h"
53
#include "stdio.h"

0 commit comments

Comments
 (0)