aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/warn/noreturn-1.C
blob: 17375d42eb76e053646e618de774ee36b5c06dd4 (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
61
62
63
64
65
66
67
68
69
70
71
// Test that noreturn attributes are properly set.
// Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-06-18.
// { dg-do compile }
// { dg-options "-Wall -O2" }

#include <cstdlib>

int foo1 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  abort();
}

int foo2 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  std::abort();
}

int foo3 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  exit(1);
}

int foo4 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  std::exit(1);
}

void __attribute__ ((__noreturn__)) foo5 ()
{
  abort();
}

void __attribute__ ((__noreturn__)) foo6 ()
{
  std::abort();
}

void __attribute__ ((__noreturn__)) foo7 ()
{
  exit(1);
}

void __attribute__ ((__noreturn__)) foo8 ()
{
  std::exit(1);
}