1*c85f09ccSJohn Levon // credit goes to Martin Uecker for the awesome ICE_P macro 2*c85f09ccSJohn Levon 3*c85f09ccSJohn Levon #define ICE_P(x) \ 4*c85f09ccSJohn Levon (__builtin_types_compatible_p(typeof(0?((void*)((long)(x)*0l)):(int*)1),int*)) 5*c85f09ccSJohn Levon 6*c85f09ccSJohn Levon #define T(x) __builtin_choose_expr(ICE_P(x), 1, 0) 7*c85f09ccSJohn Levon #define TEST(x, r) _Static_assert(T(x) == r, #x " => " #r) 8*c85f09ccSJohn Levon test(int n)9*c85f09ccSJohn Levonstatic void test(int n) 10*c85f09ccSJohn Levon { 11*c85f09ccSJohn Levon char foo[n++]; 12*c85f09ccSJohn Levon 13*c85f09ccSJohn Levon TEST(sizeof(foo), 0); 14*c85f09ccSJohn Levon } 15*c85f09ccSJohn Levon 16*c85f09ccSJohn Levon /* 17*c85f09ccSJohn Levon * check-name: vla-sizeof-ice 18*c85f09ccSJohn Levon * check-command: sparse -Wno-vla $file 19*c85f09ccSJohn Levon */ 20