aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-nothrow-3.C
blob: ed88826103f22b99a5623d4a8c31f82d0c5ee163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*  PR c++/84294 - attributes on a function template redeclaration silently
    discarded
    { dg-do compile }
    { dg-options "-O -fdump-tree-eh -fdump-tree-optimized" } */

typedef void Func ();

template <Func>
void fail_func () throw ();

template <Func test>
void test_func () throw ()
{
  try
    {
      test ();
    }
  catch (...)
    {
      // Should be eliminated.
      fail_func<test> ();
    }
}

void __attribute__ ((nothrow)) func_nothrow_none ();
void func_nothrow_none ();

template void test_func<func_nothrow_none>();


void func_none_nothrow ();
void  __attribute__ ((nothrow)) func_none_nothrow ();

template void test_func<func_none_nothrow>();


template <class>
void __attribute__ ((nothrow)) templ_nothrow_none ();

template <class>
void templa_nothrow_none ();

template void test_func<templ_nothrow_none<int> >();


template <class>
void templ_none_nothrow ();

template <class>
void  __attribute__ ((nothrow)) templ_none_nothrow ();

template void test_func<templ_none_nothrow<int> >();


// Verify that no exception handling code was emitted.
// { dg-final { scan-tree-dump-not "eh_dispatch" "eh" } }
// { dg-final { scan-tree-dump-not "resx" "eh" } }

// Verify that calls to fail_func() specializations have been eliminated.
// { dg-final { scan-tree-dump-not "fail_func" "optimized" } }