1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -fdump-tree-tailc-details" } */ 3 4 struct s { int x; }; 5 void f_direct (struct s); 6 void f_indirect (struct s *); 7 void f_void (void); 8 9 /* Tail call. */ 10 void g1(struct s param)11g1 (struct s param) 12 { 13 f_direct (param); 14 } 15 16 /* Tail call. */ 17 void g2(struct s * param_ptr)18g2 (struct s *param_ptr) 19 { 20 f_direct (*param_ptr); 21 } 22 23 /* Tail call. */ 24 void g3(struct s * param_ptr)25g3 (struct s *param_ptr) 26 { 27 f_indirect (param_ptr); 28 } 29 30 /* Tail call. */ 31 void g4(struct s * param_ptr)32g4 (struct s *param_ptr) 33 { 34 f_indirect (param_ptr); 35 f_void (); 36 } 37 38 /* Tail call. */ 39 void g5(struct s param)40g5 (struct s param) 41 { 42 struct s local = param; 43 f_direct (local); 44 } 45 46 /* Tail call. */ 47 void g6(struct s param)48g6 (struct s param) 49 { 50 struct s local = param; 51 f_direct (local); 52 f_void (); 53 } 54 55 /* Not a tail call. */ 56 void g7(struct s param)57g7 (struct s param) 58 { 59 struct s local = param; 60 f_indirect (&local); 61 } 62 63 /* Not a tail call. */ 64 void g8(struct s * param_ptr)65g8 (struct s *param_ptr) 66 { 67 struct s local = *param_ptr; 68 f_indirect (&local); 69 } 70 71 /* Not a tail call. */ 72 void g9(struct s * param_ptr)73g9 (struct s *param_ptr) 74 { 75 struct s local = *param_ptr; 76 f_indirect (&local); 77 f_void (); 78 } 79 80 /* { dg-final { scan-tree-dump-times "Found tail call" 6 "tailc" } } */ 81