| 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 |
double g() { __attribute__((musttail)) return f<int>(); } /* { dg-error "cannot tail-call" } */ |
| 8 |
|
| 9 |
template <class T> |
| 10 |
__attribute__((noinline, noclone, noipa)) |
| 11 |
T g1() { __attribute__((musttail)) return f<T>(); } /* { dg-error "target is not able" "" { target { ! external_musttail } } } */ |
| 12 |
|
| 13 |
template <class T> |
| 14 |
__attribute__((noinline, noclone, noipa)) |
| 15 |
T g2() { __attribute__((musttail)) return f<T>(); } /* { dg-error "target is not able" "" { target { ! external_musttail } } } */ |
| 16 |
|
| 17 |
template <class T> |
| 18 |
__attribute__((noinline, noclone, noipa)) |
| 19 |
/* Would work with -O1. */ |
| 20 |
T g3() { __attribute__((musttail)) return f<T>(); } /* { dg-error "cannot tail-call" } */ |
| 21 |
|
| 22 |
template <class T> |
| 23 |
__attribute__((noinline, noclone, noipa)) |
| 24 |
T g4() { __attribute__((musttail)) return f<double>(); } /* { dg-error "cannot tail-call" } */ |
| 25 |
|
| 26 |
class C |
| 27 |
{ |
| 28 |
double x; |
| 29 |
public: |
| 30 |
C(double x) : x(x) {} |
| 31 |
~C() { asm("":::"memory"); } |
| 32 |
}; |
| 33 |
|
| 34 |
int main() |
| 35 |
{ |
| 36 |
g1<int>(); |
| 37 |
g2<double>(); |
| 38 |
g3<C>(); |
| 39 |
g4<int>(); |
| 40 |
} |