Skip to content

Commit 1fa4bba

Browse files
committed
compiler compatability
1 parent 51d0269 commit 1fa4bba

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| test.c:6:19:6:40 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:32:3:32:10 | ... += ... | expression |
2-
| test.c:6:19:6:40 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:33:3:33:13 | ... = ... | expression |
3-
| test.c:10:3:10:23 | atomic_store(a,b) | Atomic variable possibly referred to twice in an $@. | test.c:10:3:10:23 | atomic_store(a,b) | expression |
4-
| test.c:11:3:11:35 | atomic_store_explicit(a,b,c) | Atomic variable possibly referred to twice in an $@. | test.c:11:3:11:35 | atomic_store_explicit(a,b,c) | expression |
5-
| test.c:24:3:24:48 | atomic_compare_exchange_weak(a,b,c) | Atomic variable possibly referred to twice in an $@. | test.c:24:3:24:48 | atomic_compare_exchange_weak(a,b,c) | expression |
6-
| test.c:25:3:26:45 | atomic_compare_exchange_weak_explicit(a,b,c,d,e) | Atomic variable possibly referred to twice in an $@. | test.c:25:3:26:45 | atomic_compare_exchange_weak_explicit(a,b,c,d,e) | expression |
1+
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:33:3:33:10 | ... += ... | expression |
2+
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:34:3:34:13 | ... = ... | expression |
3+
| test.c:11:3:11:23 | atomic_store(object,desired) | Atomic variable possibly referred to twice in an $@. | test.c:11:3:11:23 | atomic_store(object,desired) | expression |
4+
| test.c:12:3:12:23 | atomic_store_explicit | Atomic variable possibly referred to twice in an $@. | test.c:12:3:12:23 | atomic_store_explicit | expression |
5+
| test.c:25:3:25:49 | atomic_compare_exchange_weak(object,expected,desired) | Atomic variable possibly referred to twice in an $@. | test.c:25:3:25:49 | atomic_compare_exchange_weak(object,expected,desired) | expression |
6+
| test.c:26:3:26:39 | atomic_compare_exchange_weak_explicit | Atomic variable possibly referred to twice in an $@. | test.c:26:3:26:39 | atomic_compare_exchange_weak_explicit | expression |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:33:3:33:10 | ... += ... | expression |
2+
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(value) | Atomic variable possibly referred to twice in an $@. | test.c:34:3:34:13 | ... = ... | expression |
3+
| test.c:11:3:11:23 | atomic_store(object,desired) | Atomic variable possibly referred to twice in an $@. | test.c:11:3:11:23 | atomic_store(object,desired) | expression |
4+
| test.c:12:3:12:23 | atomic_store_explicit | Atomic variable possibly referred to twice in an $@. | test.c:12:3:12:23 | atomic_store_explicit | expression |
5+
| test.c:25:3:25:49 | atomic_compare_exchange_weak(object,expected,desired) | Atomic variable possibly referred to twice in an $@. | test.c:25:3:25:49 | atomic_compare_exchange_weak(object,expected,desired) | expression |
6+
| test.c:26:3:26:39 | atomic_compare_exchange_weak_explicit | Atomic variable possibly referred to twice in an $@. | test.c:26:3:26:39 | atomic_compare_exchange_weak_explicit | expression |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(VALUE) | Atomic variable possibly referred to twice in an $@. | test.c:33:3:33:10 | ... += ... | expression |
2+
| test.c:7:18:7:39 | ATOMIC_VAR_INIT(VALUE) | Atomic variable possibly referred to twice in an $@. | test.c:34:3:34:13 | ... = ... | expression |
3+
| test.c:11:3:11:23 | atomic_store(PTR,VAL) | Atomic variable possibly referred to twice in an $@. | test.c:11:3:11:23 | atomic_store(PTR,VAL) | expression |
4+
| test.c:12:3:12:35 | atomic_store_explicit(PTR,VAL,MO) | Atomic variable possibly referred to twice in an $@. | test.c:12:3:12:35 | atomic_store_explicit(PTR,VAL,MO) | expression |
5+
| test.c:25:3:25:49 | atomic_compare_exchange_weak(PTR,VAL,DES) | Atomic variable possibly referred to twice in an $@. | test.c:25:3:25:49 | atomic_compare_exchange_weak(PTR,VAL,DES) | expression |
6+
| test.c:26:3:27:42 | atomic_compare_exchange_weak_explicit(PTR,VAL,DES,SUC,FAIL) | Atomic variable possibly referred to twice in an $@. | test.c:26:3:27:42 | atomic_compare_exchange_weak_explicit(PTR,VAL,DES,SUC,FAIL) | expression |

c/cert/test/rules/CON40-C/test.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include <stdatomic.h>
22
#include <stdbool.h>
33

4-
static bool fl1 = ATOMIC_VAR_INIT(false);
5-
static bool fl2 = ATOMIC_VAR_INIT(false);
6-
static bool fl3 = ATOMIC_VAR_INIT(false);
7-
static bool fl4 = ATOMIC_VAR_INIT(false);
4+
static _Atomic int fl1 = ATOMIC_VAR_INIT(false);
5+
static _Atomic int fl2 = ATOMIC_VAR_INIT(false);
6+
static int fl2a = ATOMIC_VAR_INIT(false);
7+
static int fl3 = ATOMIC_VAR_INIT(false);
8+
static int fl4 = ATOMIC_VAR_INIT(false);
89

910
void f1() {
1011
atomic_store(&fl1, 0); // NON_COMPLIANT
@@ -13,17 +14,17 @@ void f1() {
1314

1415
void f2() {
1516
do {
16-
} while (!atomic_compare_exchange_weak(&fl2, &fl2, &fl2)); // COMPLIANT
17+
} while (!atomic_compare_exchange_weak(&fl2, &fl2a, fl2a)); // COMPLIANT
1718

1819
do {
19-
} while (!atomic_compare_exchange_weak_explicit(&fl2, &fl2, &fl2, &fl2,
20-
&fl2)); // COMPLIANT
20+
} while (!atomic_compare_exchange_weak_explicit(&fl2, &fl2a, fl2a, 0,
21+
0)); // COMPLIANT
2122
}
2223

2324
void f3() {
24-
atomic_compare_exchange_weak(&fl2, &fl2, &fl2); // NON_COMPLIANT
25-
atomic_compare_exchange_weak_explicit(&fl2, &fl2, &fl2, &fl2,
26-
&fl2); // NON_COMPLIANT
25+
atomic_compare_exchange_weak(&fl2, &fl2a, fl2a); // NON_COMPLIANT
26+
atomic_compare_exchange_weak_explicit(&fl2, &fl2a, fl2a, 0,
27+
0); // NON_COMPLIANT
2728
}
2829

2930
void f4() { fl3 ^= true; }

0 commit comments

Comments
 (0)