9
9
// - https://clang.llvm.org/docs/LanguageExtensions.html
10
10
// - https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
11
11
12
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
12
13
#ifdef __has_builtin // NON_COMPLIANT
13
14
#endif
14
15
#ifdef __has_constexpr_builtin // NON_COMPLIANT
32
33
#ifdef __has_warning // NON_COMPLIANT
33
34
#endif
34
35
36
+ // Reference: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros
35
37
#define A __BASE_FILE__ // NON_COMPLIANT
36
38
#define B __FILE_NAME__ // NON_COMPLIANT
37
39
#define C __COUNTER__ // NON_COMPLIANT
45
47
#define K __clang_literal_encoding__ // NON_COMPLIANT
46
48
#define L __clang_wide_literal_encoding__ // NON_COMPLIANT
47
49
48
- typedef float float4 __attribute__((ext_vector_type (4 ))); // NON_COMPLIANT
49
- typedef float float2 __attribute__((ext_vector_type (2 ))); // NON_COMPLIANT
50
-
51
50
// Requires additional compiler flags to change the architecture
52
51
// typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;
53
52
// typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
54
53
54
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes
55
55
typedef int int4 __attribute__((vector_size (4 * sizeof (int )))); // NON_COMPLIANT
56
-
57
56
typedef int v4si __attribute__((__vector_size__ (16 ))); // NON_COMPLIANT
58
57
typedef float float4 __attribute__((ext_vector_type (4 ))); // NON_COMPLIANT
59
58
typedef float float2 __attribute__((ext_vector_type (2 ))); // NON_COMPLIANT
60
59
61
- //// GCC features
60
+
61
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
62
62
void gf1 () {
63
- ({
63
+ ({ // NON_COMPLIANT
64
64
int y = 1 ;
65
- int z ; // NON_COMPLIANT
65
+ int z ;
66
66
if (y > 0 )
67
67
z = y ;
68
68
else
@@ -71,149 +71,154 @@ void gf1() {
71
71
});
72
72
}
73
73
74
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Local-Labels.html#Local-Labels
74
75
void gf2 () {
75
- // __label__ found; -- local labels not supported by clang
76
+ // __label__ found; // NON_COMPLIANT[FALSE_NEGATIVE] -- local labels not supported by clang
76
77
}
77
78
79
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html#Labels-as-Values
78
80
void gf3 () {
79
81
void * ptr ;
80
- // goto *ptr; -- not supported in clang
82
+ // goto *ptr; // NON_COMPLIANT[FALSE_NEGATIVE] -- not supported in clang
81
83
}
82
84
85
+ // Referfence: https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html#Nested-Functions
83
86
void gf4 () {
84
- // void gf4a(){ -- not supported in clang
87
+ // void gf4a(){ // NON_COMPLIANT[FALSE_NEGATIVE] -- not supported in clang
85
88
//
86
89
// }
87
90
}
88
91
92
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Nonlocal-Gotos.html#Nonlocal-Gotos
89
93
void gf5 () {
90
94
__builtin_setjmp (0 ); // NON_COMPLIANT
91
95
__builtin_longjmp (0 , 1 ); // NON_COMPLIANT
92
96
}
93
97
98
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Constructing-Calls.html#Constructing-Calls
94
99
void gf6 () {
95
100
// not supported by clang
96
-
97
- //__builtin_apply_args();
98
- //__builtin_apply(0, 0, 0);
99
- //__builtin_return(0);
100
- //__builtin_va_arg_pack();
101
- //__builtin_va_arg_pack_len();
101
+ //__builtin_apply_args(); // NON_COMPLIANT[FALSE_NEGATIVE]
102
+ //__builtin_apply(0, 0, 0); // NON_COMPLIANT[FALSE_NEGATIVE]
103
+ //__builtin_return(0); // NON_COMPLIANT[FALSE_NEGATIVE]
104
+ //__builtin_va_arg_pack(); // NON_COMPLIANT[FALSE_NEGATIVE]
105
+ //__builtin_va_arg_pack_len(); // NON_COMPLIANT[FALSE_NEGATIVE]
102
106
}
103
107
108
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html#Conditionals
104
109
void gf7 () {
105
110
int a = 0 ?: 0 ; // NON_COMPLIANT
106
111
}
107
112
113
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html#Typeof
108
114
void gf8 () {
109
- typeof (int * ); // NON_COMPLIANT
115
+ typeof (int * ); // NON_COMPLIANT[FALSE_NEGATIVE]
110
116
}
111
117
118
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html#g_t_005f_005fint128
112
119
void gf9 () {
113
120
__int128 a ; // NON_COMPLIANT
114
121
}
115
-
122
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Long-Long.html#Long-Long
116
123
void gf10 () {
117
124
long long int a ; // NON_COMPLIANT
118
125
}
119
126
127
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex
120
128
void gf11 () {
121
- __real__ (0 ); // NON_COMPLIANT
122
- __imag__ (0 ); // NON_COMPLIANT
129
+ __real__ (0 ); // NON_COMPLIANT[FALSE_NEGATIVE]
130
+ __imag__ (0 ); // NON_COMPLIANT[FALSE_NEGATIVE]
123
131
}
124
132
125
133
void gf12 () {}
126
134
135
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html#Floating-Types
136
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
127
137
void gf13 () {
128
138
// not supported on clang
129
-
130
- //_Decimal32 a;
131
- //_Decimal64 b;
132
- //_Decimal128 c;
139
+ //_Decimal32 a; // NON_COMPLIANT[FALSE_NEGATIVE]
140
+ //_Decimal64 b; // NON_COMPLIANT[FALSE_NEGATIVE]
141
+ //_Decimal128 c; // NON_COMPLIANT[FALSE_NEGATIVE]
133
142
}
134
143
144
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex
135
145
void gf14 () {
136
- // Not sure how to get this to work.
137
- // typedef _Complex float __attribute__((mode(TC))) _Complex128;
138
- // typedef _Complex float __attribute__((mode(XC))) _Complex80;
146
+ // Do not work in clang
147
+ // typedef _Complex float __attribute__((mode(TC))) _Complex128; // NON_COMPLIANT[FALSE_NEGATIVE]
148
+ // typedef _Complex float __attribute__((mode(XC))) _Complex80; // NON_COMPLIANT[FALSE_NEGATIVE]
139
149
}
140
150
151
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Hex-Floats.html#Hex-Floats
141
152
void gf15 () {
142
- float f = 0x1.fp3 ; // NON_COMPLIANT
153
+ float f = 0x1.fp3 ; // NON_COMPLIANT[FALSE_NEGATIVE]
143
154
}
144
155
156
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html#Zero-Length
145
157
void gf16 () {
146
158
char contents [0 ]; // NON_COMPLIANT
147
159
}
148
160
161
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#Named-Address-Spaces
149
162
void gf17 () {
150
- // const __flash char ** p; // not supported in clang
163
+ // const __flash char ** p; // NON_COMPLIANT[FALSE_NEGATIVE] -- not supported in clang
151
164
}
152
165
153
166
void gf18 () {
154
167
// not supported by extractor - checked by looking for flags.
155
168
156
- // short _Fract, _Fract;
157
- // long _Fract;
169
+ // short _Fract, _Fract; // NON_COMPLIANT[FALSE_NEGATIVE] -
170
+ // long _Fract; // NON_COMPLIANT[FALSE_NEGATIVE]
158
171
}
159
172
160
173
struct gf19 {}; // NON_COMPLIANT
161
174
175
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html#Variable-Length
162
176
void gf20 (int n ) {
163
- // struct S { int x[n]; }; // will never be supported in clang
177
+ // struct S { int x[n]; }; // NON_COMPLIANT[FALSE_NEGATIVE] - will never be supported in clang
164
178
}
165
-
179
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html#Variadic-Macros
166
180
#define gf21 (format , args ...) \
167
- printf(format, args) // NON_COMPLIANT -- note the issue here is explicitly
181
+ printf(format, args) // NON_COMPLIANT // NON_COMPLIANT[FALSE_NEGATIVE] -- note the issue here is explicitly
168
182
// naming the arguments.
169
183
#define gf21a (format , ...) printf(format, __VA_ARGS__) // COMPLIANT
170
184
185
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Escaped-Newlines.html#Escaped-Newlines
171
186
#define gf22 \
172
187
"a" \
173
188
\
174
- "b" // NON_COMPLIANT - additional spaces after a backslash
189
+ "b" // NON_COMPLIANT[FALSE_NEGATIVE] - additional spaces after a backslash -- stripped by extractor
175
190
#define gf22a \
176
191
"a" \
177
192
"b" // COMPLIANT
178
193
179
- struct gf23s {
180
- int a [1 ];
181
- };
182
- struct gf23s gf23f ();
183
- void gf23 () {
184
- gf23f ().a [0 ]; // NON_COMPLIANT in C90
185
- }
186
-
187
194
void gf24 (int f , int g ) {
188
195
float beat_freqs [2 ] = {f - g , f + g }; // NON_COMPLIANT
189
196
}
190
197
191
- void gf25t (int N , int M , double out [M ][N ], const double in [N ][M ]);
198
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html#Variable-Length
199
+ void gf25t (int N , int M , double out [M ][N ], const double in [N ][M ]); // NON_COMPLIANT[FALSE_NEGATIVE]
192
200
void gf25 () {
193
201
double x [3 ][2 ];
194
202
double y [2 ][3 ];
195
203
gf25t (3 , 2 , y ,
196
- x ); // NON_COMPLIANT - in ISO C the const qualifier is formally attached
204
+ x ); // in ISO C the const qualifier is formally attached
197
205
// to the element type of the array and not the array itself
198
206
}
199
207
208
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html#Compound-Literals
200
209
struct gf26t {
201
210
int a ;
202
211
char b [2 ];
203
212
} gf26v ;
204
213
void gf26 (int x , int y ) {
205
- gf26v = ((struct gf26t ){x + y , 'z' , 0 }); // NON_COMPLIANT - compound literal
206
- }
207
-
208
- void gf27 () {
209
- int a [6 ] = {[4 ] = 29 , [2 ] = 15 }; // NON_COMPLIANT in C90.
214
+ gf26v = ((struct gf26t ){x + y , 'z' , 0 }); // NON_COMPLIANT[FALSE_NEGATIVE] - compound literal
210
215
}
211
-
216
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html#Case-Ranges
212
217
void gf28 () {
213
218
int a ;
214
219
215
220
// switch(a){
216
- // case: 0 ... 5: // Not supported in clang.
221
+ // case: 0 ... 5: // NON_COMPLIANT[FALSE_NEGATIVE] - Not supported in clang.
217
222
// ;;
218
223
// break;
219
224
// default:
@@ -227,16 +232,19 @@ union gf29u {
227
232
double j ;
228
233
};
229
234
235
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html#Cast-to-Union
230
236
void gf29 () {
231
237
int x ;
232
238
int y ;
233
239
union gf29u z ;
234
- z = (union gf29u )x ; // NON_COMPLIANT
235
- z = (union gf29u )y ; // NON_COMPLIANT
240
+ z = (union gf29u )x ; // NON_COMPLIANT[FALSE_NEGATIVE]
241
+ z = (union gf29u )y ; // NON_COMPLIANT[FALSE_NEGATIVE]
236
242
}
237
243
238
- __attribute__((access (read_only , 1 ))) int
239
- gf30 (const char * ); // NON_COMPLIANT -- attributes are not portable.
244
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes
245
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes
246
+ __attribute__((access (read_only , 1 )))
247
+ int gf30 (const char * ); // NON_COMPLIANT -- attributes are not portable.
240
248
241
249
extern int __attribute__((alias ("var_target" )))
242
250
gf31 ; // NON_COMPLIANT -- attributes are not portable.
@@ -258,7 +266,7 @@ enum gf34 {
258
266
259
267
void gf35 () {
260
268
int x ;
261
- // __attribute__((assume(x == 42))); - Not supported in clang
269
+ // __attribute__((assume(x == 42))); // NON_COMPLIANT[FALSE_NEGATIVE] - Not supported in clang
262
270
263
271
switch (x ) {
264
272
case 1 :
@@ -269,43 +277,41 @@ void gf35() {
269
277
}
270
278
}
271
279
272
- // Not supported in clang.
273
- // int gf36 (uid_t);
274
-
275
- // int
276
- // gf36 (int x)
277
- // {
278
- // return x == 0;
279
- // }
280
-
280
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Dollar-Signs.html#Dollar-Signs
281
281
void gf37 () {
282
- int a$1 ; // NON_COMPLIANT
282
+ int a$1 ; // NON_COMPLIANT[FALSE_NEGATIVE]
283
283
}
284
284
285
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Character-Escapes.html#Character-Escapes
285
286
void gf38 () {
286
- const char * c = "test\e" ; // NON_COMPLIANT
287
+ const char * c = "test\e" ; // NON_COMPLIANT[FALSE_NEGATIVE]
287
288
}
288
289
289
290
struct gf39s {
290
291
int x ;
291
292
char y ;
292
293
} gf39v ;
293
294
295
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Alignment.html#Alignment
294
296
void gf39 () {
295
297
__alignof__(gf39v .x ); // NON_COMPLIANT
296
298
}
297
299
298
- // enum gf40 {}; // not supported in clang
300
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Incomplete-Enums.html#Incomplete-Enums
301
+ // enum gf40 {}; // NON_COMPLIANT[FALSE_NEGATIVE] - not supported in clang
299
302
303
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Function-Names.html#Function-Names
300
304
void gf41 () {
301
- printf ("__FUNCTION__ = %s\n" , __FUNCTION__ ); // NON_COMPLIANT
302
- printf ("__PRETTY_FUNCTION__ = %s\n" , __PRETTY_FUNCTION__ ); // NON_COMPLIANT
305
+ printf ("__FUNCTION__ = %s\n" , __FUNCTION__ ); // NON_COMPLIANT[FALSE_NEGATIVE]
306
+ printf ("__PRETTY_FUNCTION__ = %s\n" , __PRETTY_FUNCTION__ ); // NON_COMPLIANT[FALSE_NEGATIVE]
303
307
}
304
308
309
+ // Reference: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros
310
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
305
311
void gf42 () {
306
- __builtin_extract_return_addr (0 );
307
- __builtin_frob_return_addr (0 );
308
- __builtin_frame_address (0 );
312
+ __builtin_extract_return_addr (0 ); // NON_COMPLIANT
313
+ __builtin_frob_return_addr (0 ); // NON_COMPLIANT
314
+ __builtin_frame_address (0 ); // NON_COMPLIANT
309
315
}
310
316
311
317
struct gf43s {
@@ -322,6 +328,7 @@ struct gf44s {
322
328
char y ;
323
329
} gf44v ;
324
330
331
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins
325
332
void gf44 () {
326
333
int i ;
327
334
__sync_fetch_and_add (& i , 0 ); // NON_COMPLIANT
@@ -343,12 +350,15 @@ void gf44() {
343
350
__sync_lock_release (& i , 0 );
344
351
}
345
352
353
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html#Binary-constants
346
354
void gf45 () {
347
- int i = 0b101010 ; // NON_COMPLIANT
355
+ int i = 0b101010 ; // NON_COMPLIANT[FALSE_NEGATIVE]
348
356
}
349
357
350
- __thread int gf46 ; // NON_COMPLIANT
358
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html#Thread-Local
359
+ __thread int gf46 ; // NON_COMPLIANT[FALSE_NEGATIVE]
351
360
361
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html#Unnamed-Fields
352
362
void gf47 () { // NON_COMPLIANT in versions < C11.
353
363
struct {
354
364
int a ;
@@ -360,6 +370,7 @@ void gf47() { // NON_COMPLIANT in versions < C11.
360
370
} f ;
361
371
}
362
372
373
+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
363
374
void gf48 (){
364
375
__builtin_alloca (0 ); // NON_COMPLIANT (all __builtin functions are non-compliant.)
365
376
}
0 commit comments