| 1 |
// PR c++/97966 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template <int> |
| 5 |
struct S1 { |
| 6 |
__attribute__((used)) S1() noexcept(noexcept(this->foo())) { } |
| 7 |
void foo(); |
| 8 |
}; |
| 9 |
|
| 10 |
template <int> |
| 11 |
struct S2 { |
| 12 |
__attribute__((used)) void bar() noexcept(noexcept(this->foo())) { } |
| 13 |
void foo(); |
| 14 |
}; |
| 15 |
|
| 16 |
template <int> |
| 17 |
struct S3 { |
| 18 |
void __attribute__((used)) bar() noexcept(noexcept(this->foo())) { } |
| 19 |
void foo(); |
| 20 |
}; |
| 21 |
|
| 22 |
template <int> |
| 23 |
struct S4 { |
| 24 |
[[gnu::used]] void bar() noexcept(noexcept(this->foo())) { } |
| 25 |
void foo(); |
| 26 |
}; |
| 27 |
|
| 28 |
template <int> |
| 29 |
struct S5 { |
| 30 |
void bar() noexcept(noexcept(this->foo())) __attribute__((used)) { } |
| 31 |
void foo(); |
| 32 |
}; |
| 33 |
|
| 34 |
template <int> |
| 35 |
struct S6 { |
| 36 |
template <int> |
| 37 |
struct N { |
| 38 |
[[gnu::used]] void bar() noexcept(noexcept(this->foo())) { } |
| 39 |
void foo(); |
| 40 |
}; |
| 41 |
}; |
| 42 |
|
| 43 |
void |
| 44 |
g () |
| 45 |
{ |
| 46 |
S1<1> s1; |
| 47 |
S2<1> s2; |
| 48 |
S3<1> s3; |
| 49 |
S4<1> s4; |
| 50 |
S5<1> s5; |
| 51 |
S6<1>::N<1> n; |
| 52 |
} |
| 53 |
|
| 54 |
// Make sure that we did emit the functions marked with attribute used |
| 55 |
// even though they're not referenced in this TU. (Well, the S1() |
| 56 |
// constructor is.) |
| 57 |
// { dg-final { scan-assembler "_ZN2S1ILi1EEC1Ev" } } |
| 58 |
// { dg-final { scan-assembler "_ZN2S1ILi1EEC2Ev" } } |
| 59 |
// { dg-final { scan-assembler "_ZN2S2ILi1EE3barEv" } } |
| 60 |
// { dg-final { scan-assembler "_ZN2S3ILi1EE3barEv" } } |
| 61 |
// { dg-final { scan-assembler "_ZN2S4ILi1EE3barEv" } } |
| 62 |
// { dg-final { scan-assembler "_ZN2S5ILi1EE3barEv" } } |
| 63 |
// { dg-final { scan-assembler "_ZN2S6ILi1EE1NILi1EE3barEv" } } |