aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-nothrow-2.C
blob: 8f1d7af7d066e55a0f6e3e1aab62be11f0bc0d15 (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
/*  PR c++/83871 - wrong code for attribute const and pure on distinct
    template specializations
    Test to verify that attributes nothrow on multiple declarations of
    the same function are merged.
    { dg-do compile }
    { dg-options "-O -fdump-tree-eh" } */

void __attribute__ ((nothrow)) fnothrow ();

void test_nothrow () throw ()
{
  // No exception handling necessary around the call to fnothrow().
  fnothrow ();
}

void __attribute__ ((nothrow)) fnothrow_none ();
void fnothrow_none ();

void test_nothrow_none () throw ()
{
  // No exception handling necessary around the call to fnothrow_none().
  fnothrow_none ();
}

void fnone_nothrow ();
void __attribute__ ((nothrow)) fnone_nothrow ();

void test_none_nothrow () throw ()
{
  // No exception handling necessary around the call to fnone_nothrow().
  fnone_nothrow ();
}

int __attribute__ ((nothrow)) fnothrow_noreturn_none ();
int __attribute__ ((noreturn)) fnothrow_noreturn_none ();
int fnothrow_noreturn_none ();

int test_nothrow_noreturn_none () throw ()
{
  // No exception handling necessary around the call().
  // No -Wreturn-value should be emitted because the function is
  // declared noreturn.
  fnothrow_noreturn_none ();
}

// 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" } }