Home | History | Annotate | Line # | Download | only in lint1
gcc_builtin_alloca.c revision 1.3
      1 /*	$NetBSD: gcc_builtin_alloca.c,v 1.3 2022/06/22 19:23:18 rillig Exp $	*/
      2 # 3 "gcc_builtin_alloca.c"
      3 
      4 /*
      5  * Test for the GCC builtin functions __builtin_alloca*, which unlike most
      6  * other builtin functions return a pointer instead of int.
      7  *
      8  * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
      9  */
     10 
     11 void
     12 example(void)
     13 {
     14 	char *ptr = __builtin_alloca(8);
     15 	ptr[4] = '4';
     16 
     17 	char *aligned_ptr = __builtin_alloca_with_align(8, 64);
     18 	aligned_ptr[0] = '\0';
     19 
     20 	/* expect+1: warning: illegal combination of pointer 'pointer to char' and integer 'int' [183] */
     21 	char *unknown = __builtin_allocate(8);
     22 	unknown[0] = '\0';
     23 }
     24