1 /* Allow nested functions. */ 2 /* { dg-options "-Wno-pedantic" } */ 3 4 struct box { char field[64]; int i; }; 5 6 struct box __attribute__((noinline,noclone)) returns_struct(int i)7returns_struct (int i) 8 { 9 struct box b; 10 b.i = i * i; 11 return b; 12 } 13 14 int __attribute__((noinline,noclone)) test_1(int i)15test_1 (int i) 16 { 17 return returns_struct (i * 5).i; /* { dg-error "cannot tail-call: " } */ 18 } 19 20 int __attribute__((noinline,noclone)) test_2_callee(int i,struct box b)21test_2_callee (int i, struct box b) 22 { 23 if (b.field[0]) 24 return 5; 25 return i * i; 26 } 27 28 int __attribute__((noinline,noclone)) test_2_caller(int i)29test_2_caller (int i) 30 { 31 struct box b; 32 return test_2_callee (i + 1, b); /* { dg-error "cannot tail-call: " } */ 33 } 34 35 extern void setjmp (void); 36 void test_3(void)37test_3 (void) 38 { 39 setjmp (); /* { dg-error "cannot tail-call: " } */ 40 } 41 42 void test_4(void)43test_4 (void) 44 { 45 void nested (void) 46 { 47 } 48 nested (); /* { dg-error "cannot tail-call: " } */ 49 } 50 51 typedef void (fn_ptr_t) (void); 52 volatile fn_ptr_t fn_ptr; 53 54 void test_5(void)55test_5 (void) 56 { 57 fn_ptr (); /* { dg-error "cannot tail-call: " } */ 58 } 59