1 /* $NetBSD: msg_343.c,v 1.5 2021/07/15 21:00:05 rillig Exp $ */ 2 # 3 "msg_343.c" 3 4 /* Test for message: static array size is a C11 extension [343] */ 5 6 /* lint1-flags: -Sw */ 7 8 void takes_int_pointer(int []); 9 void takes_int_pointer_with_ignored_size(int [3]); 10 void takes_int_array(int[static 3]); /* expect: 343 */ 11 /* expect+1: syntax error '3' */ 12 void takes_volatile_int_array(int[volatile 3]); 13 14 int 15 returns_int_pointer(int a[]) 16 { 17 return a[0]; 18 } 19 20 int 21 returns_int_pointer_with_ignored_size(int a[3]) 22 { 23 return a[0]; 24 } 25 26 int 27 returns_int_array(int a[static 3]) /* expect: 343 */ 28 { 29 return a[0]; 30 } 31 32 int 33 /* expect+1: syntax error '3' */ 34 returns_volatile_int_array(int a[volatile 3]) 35 { 36 /* expect+2: cannot dereference non-pointer type */ 37 /* expect+1: expects to return value */ 38 return a[0]; 39 } 40 41 /* 42 * This triggers the "Bad attribute", but for some reason, that custom error 43 * message does not make it into the actual diagnostic. 44 */ 45 /* expect+2: error: syntax error ']' [249] */ 46 /* expect+1: error: static array size is a C11 extension [343] */ 47 void invalid_storage_class(int a[const typedef 3]); 48