Home | History | Annotate | Line # | Download | only in lint1
gcc.c revision 1.2
      1 /*	$NetBSD: gcc.c,v 1.2 2024/06/08 11:55:40 rillig Exp $	*/
      2 # 3 "gcc.c"
      3 
      4 /*
      5  * Miscellaneous tests that are specific to lint's GCC mode.
      6  */
      7 
      8 /* lint1-extra-flags: -X 351 */
      9 
     10 // Before C99 introduced __func__, GCC already had __FUNCTION__ with the same
     11 // semantics.
     12 const char *
     13 gcc_function(void)
     14 {
     15 	/* expect+1: error: negative array dimension (-13) [20] */
     16 	typedef int size[-(int)sizeof __FUNCTION__];
     17 
     18 	return __FUNCTION__;
     19 }
     20 
     21 // Before C99 introduced designators in initializers, GCC already had them,
     22 // although with a different syntax for struct/union members and with the
     23 // a...b for ranges of array elements.
     24 int array_range_initializers[256] = {
     25 	[2] = 1,
     26 	[3] = 2,
     27 	[4 ... 5] = 3
     28 };
     29 
     30 _Bool dbl_isinf(double);
     31 
     32 // Test that the GCC '__extension__' and '__typeof' are recognized.
     33 void
     34 extension_and_typeof(void)
     35 {
     36 	double __logbw = 1;
     37 	if (__extension__(({
     38 		__typeof((__logbw)) x_ = (__logbw);
     39 		!dbl_isinf((x_));
     40 	})))
     41 		__logbw = 1;
     42 }
     43 
     44 int
     45 range_in_case_label(int i)
     46 {
     47 	switch (i) {
     48 	case 1 ... 40:		// This is a GCC extension.
     49 		return 1;
     50 	default:
     51 		return 2;
     52 	}
     53 }
     54