PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / c99-static-1.c
bloba138f878d928b60e919c215f8b51dfd20ff82ed5
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; }
21 /* OK. */
22 static int f3(void);
23 void g3(void) { sizeof(f3()); }
25 /* OK (VM type, not VLA). */
26 static int f4(void);
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). */
34 static int f6(void);
35 void g6(void) { sizeof(sizeof(int [f6()])); }