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" } */
9 /* Constraint violation (trivial case, where function is used). */
10 static void f0(void); /* { dg-error "used but never defined" } */
11 void g0(void) { f0(); }
13 /* Constraint violation. */
14 static void f1(void); /* { dg-error "used but never defined" } */
15 void g1(void) { if (0) { f1(); } }
17 /* Constraint violation. */
18 static int f2(void); /* { dg-error "used but never defined" } */
19 void g2(void) { 0 ? f2() : 0; }
23 void g3(void) { sizeof(f3()); }
25 /* OK (VM type, not VLA). */
27 void g4(void) { sizeof(int (*)[f4()]); }
29 /* Constraint violation (VLA). */
30 static int f5(void); /* { dg-error "used but never defined" "VLA" } */
31 void g5(void) { sizeof(int [0 ? f5() : 1]); }
33 /* OK (non-constant sizeof inside constant sizeof). */
35 void g6(void) { sizeof(sizeof(int [f6()])); }