[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / ext / attr-nothrow.C
blob1d3d7153b8d276735747f3fa9d023a2d57ca6cfa
1 // Bug c++/83871 - wrong code due to attributes on distinct template
2 // specializations
3 // Test to verify that an explicit template specifialization does not
4 // "inherit" attribute nothrow from a primary template declared with one.
5 // { dg-do compile }
6 // { dg-options "-O -Wall -fdump-tree-optimized" }
8 template <class T>
9 void __attribute__ ((nothrow))
10 f ();
12 template <>
13 void f<int>();
15 void f_void_nothrow ();
16 void f_int_maythrow ();
18 void fv (void)
20   try
21     {
22       f<void>();
23     }
24   catch (...)                    // cannot be be reached
25     {
26       f_void_nothrow ();         // should be eliminated
27     }
31 void fi (void)
33   try
34     {
35       f<int>();
36     }
37   catch (...)                    // may be reached
38     {
39       f_int_maythrow ();         // must not be eliminated
40     }
43 // Verify that the call to f_void_nothrow() is eliminated but
44 // the call to f_int_maythrow() is retained.
45 // { dg-final { scan-tree-dump-not "f_void_nothrow" "optimized" } }
46 // { dg-final { scan-tree-dump-times "f_int_maythrow" 1 "optimized" } }