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. The use of the function simply
4 being unevaluated is not enough. */
5 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
6 /* { dg-do compile } */
7 /* { dg-options "-O2 -std=iso9899:1999 -pedantic-errors" } */
8
9 /* Constraint violation (trivial case, where function is used). */
10 static void f0(void); /* { dg-error "used but never defined" } */
g0(void)11 void g0(void) { f0(); }
12
13 /* Constraint violation. */
14 static void f1(void); /* { dg-error "used but never defined" } */
g1(void)15 void g1(void) { if (0) { f1(); } }
16
17 /* Constraint violation. */
18 static int f2(void); /* { dg-error "used but never defined" } */
g2(void)19 void g2(void) { 0 ? f2() : 0; }
20
21 /* OK. */
22 static int f3(void);
g3(void)23 void g3(void) { sizeof(f3()); }
24
25 /* OK (VM type, not VLA). */
26 static int f4(void);
g4(void)27 void g4(void) { sizeof(int (*)[f4()]); }
28
29 /* Constraint violation (VLA). */
30 static int f5(void); /* { dg-error "used but never defined" "VLA" } */
g5(void)31 void g5(void) { sizeof(int [0 ? f5() : 1]); }
32
33 /* OK (non-constant sizeof inside constant sizeof). */
34 static int f6(void);
g6(void)35 void g6(void) { sizeof(sizeof(int [f6()])); }
36