Debian Codegraph @

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

raw
1 /* { dg-do compile { target { musttail } } } */
2 /* { dg-options "-std=gnu++11" } */
3 /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
4
5 template <class T> T f();
6
7 class C
8 {
9 double x;
10 public:
11 C(double x) : x(x) {}
12 ~C() { asm("":::"memory"); }
13 operator int() { return x; }
14 };
15
16 template <class T>
17 __attribute__((noinline, noclone, noipa))
18 T g5() { [[gnu::musttail]] return f<C> (); } /* { dg-error "cannot tail-call" } */
19
20 C h();
21
22 __attribute__((noinline, noclone, noipa))
23 int g6() { [[gnu::musttail]] return h (); } /* { dg-error "cannot tail-call" } */
24
25 __attribute__((noinline, noclone, noipa))
26 C g7() { [[gnu::musttail]] return h (); } /* { dg-error "cannot tail-call" } */
27
28 int main()
29 {
30 g5<int> ();
31 g6 ();
32 g7 ();
33 }