| 1 |
/* PR c++/84294 - attributes on a function template redeclaration silently |
| 2 |
discarded |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-O -fdump-tree-optimized" } */ |
| 5 |
|
| 6 |
typedef void Func (); |
| 7 |
|
| 8 |
template <Func> |
| 9 |
void fail_func (); |
| 10 |
|
| 11 |
template <Func test> |
| 12 |
int test_func () |
| 13 |
{ |
| 14 |
test (); |
| 15 |
|
| 16 |
// Should be eliminated. |
| 17 |
fail_func<test> (); |
| 18 |
|
| 19 |
// Expect no -Wreturn type here despite the absence of a return |
| 20 |
// statement in a non-void function. |
| 21 |
} // { dg-bogus "\\\[-Wreturn-type]" "bug 84621" { xfail *-*-* } } |
| 22 |
|
| 23 |
void __attribute__ ((noreturn)) func_noreturn_none (); |
| 24 |
void func_noreturn_none (); |
| 25 |
|
| 26 |
template int test_func<func_noreturn_none>(); |
| 27 |
|
| 28 |
|
| 29 |
void func_none_noreturn (); |
| 30 |
void __attribute__ ((noreturn)) func_none_noreturn (); |
| 31 |
|
| 32 |
template int test_func<func_none_noreturn>(); |
| 33 |
|
| 34 |
|
| 35 |
template <class> |
| 36 |
void __attribute__ ((noreturn)) templ_noreturn_none (); |
| 37 |
|
| 38 |
template <class> |
| 39 |
void templa_noreturn_none (); |
| 40 |
|
| 41 |
template int test_func<templ_noreturn_none<int> >(); |
| 42 |
|
| 43 |
|
| 44 |
template <class> |
| 45 |
void templ_none_noreturn (); |
| 46 |
|
| 47 |
template <class> |
| 48 |
void __attribute__ ((noreturn)) templ_none_noreturn (); |
| 49 |
|
| 50 |
template int test_func<templ_none_noreturn<int> >(); |
| 51 |
|
| 52 |
|
| 53 |
// Verify that calls to fail_func() specializations have been eliminated. |
| 54 |
// { dg-final { scan-tree-dump-not "fail_func" "optimized" } } |