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