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