Debian Codegraph @

gcc/testsuite/g++.dg/musttail14.C

raw
1 // PR tree-optimization/118430
2 // { dg-do compile { target musttail } }
3 // { dg-options "-O2 -fdump-tree-optimized" }
4 // { dg-final { scan-tree-dump-times " \[^\n\r]* = foo \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
5 // { dg-final { scan-tree-dump-times " \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
6 // { dg-final { scan-tree-dump-times " \[^\n\r]* = baz \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
7 // { dg-final { scan-tree-dump-times " \[^\n\r]* = qux \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
8 // { dg-final { scan-tree-dump-times " \[^\n\r]* = corge \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
9 // { dg-final { scan-tree-dump-times " \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
10
11 __attribute__ ((noipa)) int
12 foo (int x)
13 {
14 return x;
15 }
16
17 __attribute__ ((noipa)) int
18 bar (int x)
19 {
20 return x;
21 }
22
23 __attribute__ ((noipa)) int
24 baz (int x)
25 {
26 return x;
27 }
28
29 __attribute__ ((noipa)) int
30 qux (int x)
31 {
32 return x;
33 }
34
35 __attribute__ ((noipa)) int
36 corge (int x)
37 {
38 return x;
39 }
40
41 __attribute__ ((noipa)) int
42 freddy (int x)
43 {
44 return x;
45 }
46
47 int
48 garply (int x)
49 {
50 switch (x)
51 {
52 case 0:
53 [[]] __attribute__(()) [[]] __attribute__((musttail)) [[]] return foo (42);
54 case 1:
55 [[]] __attribute__(()) [[gnu::musttail]] __attribute__(()) [[]] return bar (43);
56 case 2:
57 __attribute__(()) [[]] __attribute__((musttail)) [[]] __attribute__(()) return baz (44);
58 case 3:
59 __attribute__(()) [[gnu::musttail]] __attribute__(()) [[]] __attribute__(()) return qux (45);
60 case 4:
61 [[]] __attribute__(()) [[clang::musttail]] __attribute__(()) [[]] return corge (46);
62 default:
63 __attribute__(()) [[clang::musttail]] __attribute__(()) [[]] __attribute__(()) return freddy (47);
64 }
65 }