Skip to content

Commit cec1948

Browse files
Use clang-format v11, which is closer to v14 installed on ci/cd
1 parent 64b7684 commit cec1948

File tree

8 files changed

+270
-268
lines changed

8 files changed

+270
-268
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// NON_COMPLIANT:
2-
#define M1 _Generic(1, int: 1)
2+
#define M1 _Generic(1, int : 1)
33
// NON_COMPLIANT:
4-
#define M2(X) _Generic(1, int: X)
4+
#define M2(X) _Generic(1, int : X)
55
// COMPLIANT:
6-
#define M3(X) _Generic((X), int: 1)
6+
#define M3(X) _Generic((X), int : 1)
77
// COMPLIANT:
8-
#define M4(X) _Generic((X), int: 1)
8+
#define M4(X) _Generic((X), int : 1)
99
// COMPLIANT:
10-
#define M5(X) _Generic((X + X), int: 1)
10+
#define M5(X) _Generic((X + X), int : 1)
1111
int f1(int a, int b);
1212
// COMPLIANT:
13-
#define M6(X) _Generic(f(1, (X)), int: 1)
14-
#define M7(X) 1 + _Generic((X), int: 1)
13+
#define M6(X) _Generic(f(1, (X)), int : 1)
14+
#define M7(X) 1 + _Generic((X), int : 1)
1515
// COMPLIANT:
16-
#define M8(X) g(_Generic((X), int: 1))
16+
#define M8(X) g(_Generic((X), int : 1))
1717
// NON_COMPLIANT:
18-
#define M9(X) g(_Generic((Y), int: 1))
18+
#define M9(X) g(_Generic((Y), int : 1))
1919

2020
void f2() {
21-
_Generic(1, int: 1); // NON_COMPLIANT
22-
M1; // NON_COMPLIANT
23-
M2(1); // NON_COMPLIANT
24-
M3(1); // COMPLIANT
21+
_Generic(1, int : 1); // NON_COMPLIANT
22+
M1; // NON_COMPLIANT
23+
M2(1); // NON_COMPLIANT
24+
M3(1); // COMPLIANT
2525
}

c/misra/test/rules/RULE-23-2/test.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
#define M1(X) _Generic((X), int: 1)
1+
#define M1(X) _Generic((X), int : 1)
22

33
// NON_COMPLIANT:
4-
#define M2(X) _Generic((X)++, int: 1)
4+
#define M2(X) _Generic((X)++, int : 1)
55

66
// NON_COMPLIANT:
7-
#define M3(X) _Generic(l1++, int: (X))
7+
#define M3(X) _Generic(l1++, int : (X))
88

99
// COMPLIANT:
1010
#define M3_WRAPPER(X) M3(X)
1111

12-
#define M4(X) _Generic((X)(), int: 1)
12+
#define M4(X) _Generic((X)(), int : 1)
1313

1414
void f1() {
1515
int l1;
1616

17-
_Generic(1, int: 1); // COMPLIANT
18-
M1(1); // COMPLIANT
19-
_Generic(l1, int: 1); // COMPLIANT
20-
M1(l1); // COMPLIANT
17+
_Generic(1, int : 1); // COMPLIANT
18+
M1(1); // COMPLIANT
19+
_Generic(l1, int : 1); // COMPLIANT
20+
M1(l1); // COMPLIANT
2121

2222
_Generic(l1++,
23-
int: 1); // COMPLIANT: side effect is not from a macro argument.
24-
M1(l1++); // COMPLIANT
25-
M2(l1); // NON-COMPLIANT: at macro definition
26-
M3(1); // NON-COMPLIANT: at macro definition
27-
M3_WRAPPER(1); // NON-COMPLIANT: at definition of M3
23+
int : 1); // COMPLIANT: side effect is not from a macro argument.
24+
M1(l1++); // COMPLIANT
25+
M2(l1); // NON-COMPLIANT: at macro definition
26+
M3(1); // NON-COMPLIANT: at macro definition
27+
M3_WRAPPER(1); // NON-COMPLIANT: at definition of M3
2828
}
2929

3030
int g1;
@@ -41,7 +41,7 @@ void f2() {
4141

4242
#define M5(X) \
4343
static volatile l##X; \
44-
_Generic(l##X, int: 1)
44+
_Generic(l##X, int : 1)
4545

4646
void f3() {
4747
M5(a); // NON-COMPLIANT

c/misra/test/rules/RULE-23-3/test.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// NON-COMPLIANT
2-
#define M1 _Generic(1, default: 1);
2+
#define M1 _Generic(1, default : 1);
33
// COMPLIANT
4-
#define M2 _Generic(1, int: 1);
4+
#define M2 _Generic(1, int : 1);
55
// COMPLIANT
6-
#define M3 _Generic(1, int: 1, default: 1);
6+
#define M3 _Generic(1, int : 1, default : 1);
77
// COMPLIANT
8-
#define M4 _Generic(1, int: 1, long: 1);
8+
#define M4 _Generic(1, int : 1, long : 1);
99

1010
void f() {
1111
// Invalid generics:
1212
// _Generic(1);
1313
// _Generic(1, void: 1);
14-
_Generic(1, default: 1); // NON-COMPLIANT
15-
_Generic(1, int: 1); // COMPLIANT
16-
_Generic(1, int: 1, default: 1); // COMPLIANT
17-
_Generic(1, int: 1, long: 1); // COMPLIANT
14+
_Generic(1, default : 1); // NON-COMPLIANT
15+
_Generic(1, int : 1); // COMPLIANT
16+
_Generic(1, int : 1, default : 1); // COMPLIANT
17+
_Generic(1, int : 1, long : 1); // COMPLIANT
1818

1919
M1;
2020
M2;

c/misra/test/rules/RULE-23-4/test.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,41 @@ union empty_union {};
77

88
void f() {
99
_Generic(1,
10-
int: 1, // COMPLIANT
11-
const int: 1, // NON-COMPLIANT
12-
volatile int: 1, // NON-COMPLIANT
13-
_Atomic int: 1, // NON-COMPLIANT
14-
int *: 1, // COMPLIANT
15-
int const *: 1, // COMPLIANT
16-
const volatile int: 1, // NON-COMPLIANT
17-
int volatile const *: 1, // COMPLIANT
18-
struct {}: 1, // NON-COMPLIANT
19-
struct {} *: 1, // NON-COMPLIANT
20-
empty_struct_t: 1, // COMPLIANT
21-
struct empty_struct: 1, // COMPLIANT
22-
empty_struct_t *: 1, // COMPLIANT
23-
struct empty_struct *: 1, // COMPLIANT
24-
union {}: 1, // NON-COMPLIANT
25-
union {} *: 1, // NON-COMPLIANT
26-
empty_union_t: 1, // COMPLIANT
27-
union empty_union: 1, // COMPLIANT
28-
empty_union_t *: 1, // COMPLIANT
29-
union empty_union *: 1, // COMPLIANT
30-
// int[]: 1, // compile error
31-
int[3]: 1, // NON-COMPLIANT
32-
int(*)[3]: 1, // COMPLIANT: pointer to array OK
33-
// int (int*): 1, // compile error
34-
int (*)(int *): 1, // COMPLIANT: function pointers OK
35-
default: 1 // COMPLIANT
10+
int : 1, // COMPLIANT
11+
const int : 1, // NON-COMPLIANT
12+
volatile int : 1, // NON-COMPLIANT
13+
_Atomic int : 1, // NON-COMPLIANT
14+
int * : 1, // COMPLIANT
15+
int const * : 1, // COMPLIANT
16+
const volatile int : 1, // NON-COMPLIANT
17+
int volatile const * : 1, // COMPLIANT
18+
struct {} : 1, // NON-COMPLIANT
19+
struct {} * : 1, // NON-COMPLIANT
20+
empty_struct_t : 1, // COMPLIANT
21+
struct empty_struct : 1, // COMPLIANT
22+
empty_struct_t * : 1, // COMPLIANT
23+
struct empty_struct * : 1, // COMPLIANT
24+
union {} : 1, // NON-COMPLIANT
25+
union {} * : 1, // NON-COMPLIANT
26+
empty_union_t : 1, // COMPLIANT
27+
union empty_union : 1, // COMPLIANT
28+
empty_union_t * : 1, // COMPLIANT
29+
union empty_union * : 1, // COMPLIANT
30+
// int[]: 1, // compile error
31+
int[3] : 1, // NON-COMPLIANT
32+
int(*)[3] : 1, // COMPLIANT: pointer to array OK
33+
// int (int*): 1, // compile error
34+
int (*)(int *) : 1, // COMPLIANT: function pointers OK
35+
default : 1 // COMPLIANT
3636
);
3737
}
3838

3939
// NON-COMPLIANT
40-
#define M1(X) _Generic((X), const int: 1, default: 0)
40+
#define M1(X) _Generic((X), const int : 1, default : 0)
4141
// NON-COMPLIANT
42-
#define M2(X) _Generic(1, X[3]: 1, default: 0)
42+
#define M2(X) _Generic(1, X[3] : 1, default : 0)
4343
// COMPLIANT
44-
#define M3(X) _Generic(1, X: 1, default: 0)
44+
#define M3(X) _Generic(1, X : 1, default : 0)
4545

4646
void f2() {
4747
M1(1);
@@ -60,12 +60,12 @@ typedef long const *long_const_ptr;
6060

6161
void f3() {
6262
_Generic(1,
63-
int_t: 1, // COMPLIANT
64-
const_int: 1, // NON-COMPLIANT
65-
const_int_ptr: 1, // COMPLIANT
66-
long_const_ptr: 1, // COMPLIANT
67-
const int_ptr: 1, // COMPLIANT
68-
default: 1 // COMPLIANT
63+
int_t : 1, // COMPLIANT
64+
const_int : 1, // NON-COMPLIANT
65+
const_int_ptr : 1, // COMPLIANT
66+
long_const_ptr : 1, // COMPLIANT
67+
const int_ptr : 1, // COMPLIANT
68+
default : 1 // COMPLIANT
6969
);
7070
}
7171

0 commit comments

Comments
 (0)