99// - https://clang.llvm.org/docs/LanguageExtensions.html
1010// - https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
1111
12+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
1213#ifdef __has_builtin // NON_COMPLIANT
1314#endif
1415#ifdef __has_constexpr_builtin // NON_COMPLIANT
3233#ifdef __has_warning // NON_COMPLIANT
3334#endif
3435
36+ // Reference: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros
3537#define A __BASE_FILE__ // NON_COMPLIANT
3638#define B __FILE_NAME__ // NON_COMPLIANT
3739#define C __COUNTER__ // NON_COMPLIANT
4547#define K __clang_literal_encoding__ // NON_COMPLIANT
4648#define L __clang_wide_literal_encoding__ // NON_COMPLIANT
4749
48- typedef float float4 __attribute__((ext_vector_type (4 ))); // NON_COMPLIANT
49- typedef float float2 __attribute__((ext_vector_type (2 ))); // NON_COMPLIANT
50-
5150// Requires additional compiler flags to change the architecture
5251// typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;
5352// typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
5453
54+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes
5555typedef int int4 __attribute__((vector_size (4 * sizeof (int )))); // NON_COMPLIANT
56-
5756typedef int v4si __attribute__((__vector_size__ (16 ))); // NON_COMPLIANT
5857typedef float float4 __attribute__((ext_vector_type (4 ))); // NON_COMPLIANT
5958typedef float float2 __attribute__((ext_vector_type (2 ))); // NON_COMPLIANT
6059
61- //// GCC features
60+
61+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
6262void gf1 () {
63- ({
63+ ({ // NON_COMPLIANT
6464 int y = 1 ;
65- int z ; // NON_COMPLIANT
65+ int z ;
6666 if (y > 0 )
6767 z = y ;
6868 else
@@ -71,149 +71,154 @@ void gf1() {
7171 });
7272}
7373
74+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Local-Labels.html#Local-Labels
7475void gf2 () {
75- // __label__ found; -- local labels not supported by clang
76+ // __label__ found; // NON_COMPLIANT[FALSE_NEGATIVE] -- local labels not supported by clang
7677}
7778
79+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html#Labels-as-Values
7880void gf3 () {
7981 void * ptr ;
80- // goto *ptr; -- not supported in clang
82+ // goto *ptr; // NON_COMPLIANT[FALSE_NEGATIVE] -- not supported in clang
8183}
8284
85+ // Referfence: https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html#Nested-Functions
8386void gf4 () {
84- // void gf4a(){ -- not supported in clang
87+ // void gf4a(){ // NON_COMPLIANT[FALSE_NEGATIVE] -- not supported in clang
8588 //
8689 // }
8790}
8891
92+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Nonlocal-Gotos.html#Nonlocal-Gotos
8993void gf5 () {
9094 __builtin_setjmp (0 ); // NON_COMPLIANT
9195 __builtin_longjmp (0 , 1 ); // NON_COMPLIANT
9296}
9397
98+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Constructing-Calls.html#Constructing-Calls
9499void gf6 () {
95100 // 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]
102106}
103107
108+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html#Conditionals
104109void gf7 () {
105110 int a = 0 ?: 0 ; // NON_COMPLIANT
106111}
107112
113+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html#Typeof
108114void gf8 () {
109- typeof (int * ); // NON_COMPLIANT
115+ typeof (int * ); // NON_COMPLIANT[FALSE_NEGATIVE]
110116}
111117
118+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html#g_t_005f_005fint128
112119void gf9 () {
113120 __int128 a ; // NON_COMPLIANT
114121}
115-
122+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Long-Long.html#Long-Long
116123void gf10 () {
117124 long long int a ; // NON_COMPLIANT
118125}
119126
127+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex
120128void 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]
123131}
124132
125133void gf12 () {}
126134
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
127137void gf13 () {
128138 // 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]
133142}
134143
144+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex
135145void 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]
139149}
140150
151+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Hex-Floats.html#Hex-Floats
141152void gf15 () {
142- float f = 0x1.fp3 ; // NON_COMPLIANT
153+ float f = 0x1.fp3 ; // NON_COMPLIANT[FALSE_NEGATIVE]
143154}
144155
156+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html#Zero-Length
145157void gf16 () {
146158 char contents [0 ]; // NON_COMPLIANT
147159}
148160
161+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#Named-Address-Spaces
149162void gf17 () {
150- // const __flash char ** p; // not supported in clang
163+ // const __flash char ** p; // NON_COMPLIANT[FALSE_NEGATIVE] -- not supported in clang
151164}
152165
153166void gf18 () {
154167 // not supported by extractor - checked by looking for flags.
155168
156- // short _Fract, _Fract;
157- // long _Fract;
169+ // short _Fract, _Fract; // NON_COMPLIANT[FALSE_NEGATIVE] -
170+ // long _Fract; // NON_COMPLIANT[FALSE_NEGATIVE]
158171}
159172
160173struct gf19 {}; // NON_COMPLIANT
161174
175+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html#Variable-Length
162176void 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
164178}
165-
179+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html#Variadic-Macros
166180#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
168182 // naming the arguments.
169183#define gf21a (format , ...) printf(format, __VA_ARGS__) // COMPLIANT
170184
185+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Escaped-Newlines.html#Escaped-Newlines
171186#define gf22 \
172187 "a" \
173188 \
174- "b" // NON_COMPLIANT - additional spaces after a backslash
189+ "b" // NON_COMPLIANT[FALSE_NEGATIVE] - additional spaces after a backslash -- stripped by extractor
175190#define gf22a \
176191 "a" \
177192 "b" // COMPLIANT
178193
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-
187194void gf24 (int f , int g ) {
188195 float beat_freqs [2 ] = {f - g , f + g }; // NON_COMPLIANT
189196}
190197
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]
192200void gf25 () {
193201 double x [3 ][2 ];
194202 double y [2 ][3 ];
195203 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
197205 // to the element type of the array and not the array itself
198206}
199207
208+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html#Compound-Literals
200209struct gf26t {
201210 int a ;
202211 char b [2 ];
203212} gf26v ;
204213void 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
210215}
211-
216+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html#Case-Ranges
212217void gf28 () {
213218 int a ;
214219
215220 // switch(a){
216- // case: 0 ... 5: // Not supported in clang.
221+ // case: 0 ... 5: // NON_COMPLIANT[FALSE_NEGATIVE] - Not supported in clang.
217222 // ;;
218223 // break;
219224 // default:
@@ -227,16 +232,19 @@ union gf29u {
227232 double j ;
228233};
229234
235+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html#Cast-to-Union
230236void gf29 () {
231237 int x ;
232238 int y ;
233239 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]
236242}
237243
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.
240248
241249extern int __attribute__((alias ("var_target" )))
242250gf31 ; // NON_COMPLIANT -- attributes are not portable.
@@ -258,7 +266,7 @@ enum gf34 {
258266
259267void gf35 () {
260268 int x ;
261- // __attribute__((assume(x == 42))); - Not supported in clang
269+ // __attribute__((assume(x == 42))); // NON_COMPLIANT[FALSE_NEGATIVE] - Not supported in clang
262270
263271 switch (x ) {
264272 case 1 :
@@ -269,43 +277,41 @@ void gf35() {
269277 }
270278}
271279
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
281281void gf37 () {
282- int a$1 ; // NON_COMPLIANT
282+ int a$1 ; // NON_COMPLIANT[FALSE_NEGATIVE]
283283}
284284
285+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Character-Escapes.html#Character-Escapes
285286void gf38 () {
286- const char * c = "test\e" ; // NON_COMPLIANT
287+ const char * c = "test\e" ; // NON_COMPLIANT[FALSE_NEGATIVE]
287288}
288289
289290struct gf39s {
290291 int x ;
291292 char y ;
292293} gf39v ;
293294
295+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Alignment.html#Alignment
294296void gf39 () {
295297 __alignof__(gf39v .x ); // NON_COMPLIANT
296298}
297299
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
299302
303+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Function-Names.html#Function-Names
300304void 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]
303307}
304308
309+ // Reference: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros
310+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
305311void 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
309315}
310316
311317struct gf43s {
@@ -322,6 +328,7 @@ struct gf44s {
322328 char y ;
323329} gf44v ;
324330
331+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins
325332void gf44 () {
326333 int i ;
327334 __sync_fetch_and_add (& i , 0 ); // NON_COMPLIANT
@@ -343,12 +350,15 @@ void gf44() {
343350 __sync_lock_release (& i , 0 );
344351}
345352
353+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html#Binary-constants
346354void gf45 () {
347- int i = 0b101010 ; // NON_COMPLIANT
355+ int i = 0b101010 ; // NON_COMPLIANT[FALSE_NEGATIVE]
348356}
349357
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]
351360
361+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html#Unnamed-Fields
352362void gf47 () { // NON_COMPLIANT in versions < C11.
353363 struct {
354364 int a ;
@@ -360,6 +370,7 @@ void gf47() { // NON_COMPLIANT in versions < C11.
360370 } f ;
361371}
362372
373+ // Reference: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
363374void gf48 (){
364375 __builtin_alloca (0 ); // NON_COMPLIANT (all __builtin functions are non-compliant.)
365376}
0 commit comments