1 /* It is a constraint violation for a static function to be declared
2 but not defined if it is used except in a sizeof expression whose
3 result is an integer constant. In GNU C, we need to consider
4 __typeof__ and __alignof__ as well. __alignof__ always returns a
5 constant, so static functions can always be used therein.
6 __typeof__ evaluates its argument iff it has variably modified
8 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
9 /* { dg-do compile } */
10 /* { dg-options "-O2 -std=gnu99 -pedantic-errors" } */
12 /* __alignof__, OK. */
14 void g0(void) { __alignof__(f0()); }
16 /* __typeof__ not variably modified, OK. */
18 void g1(void) { __typeof__(f1()) x
; }
20 /* __typeof__ variably modified, not OK. */
21 static int f2(void); /* { dg-error "used but never defined" } */
22 void g2(void) { __typeof__(int [f2()]) x
; }
24 /* __typeof__ variably modified, not OK. */
25 static int f3(void); /* { dg-error "used but never defined" } */
26 void g3(void) { __typeof__(int (*)[f3()]) x
; }
28 /* Integer sizeof of VM typeof, OK. */
30 void g4(void) { sizeof(__typeof__(int (*)[f3()])); }