2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / warn / noreturn-1.C
blob17375d42eb76e053646e618de774ee36b5c06dd4
1 // Test that noreturn attributes are properly set.
2 // Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-06-18.
3 // { dg-do compile }
4 // { dg-options "-Wall -O2" }
6 #include <cstdlib>
8 int foo1 (int i)
10   switch (i)
11     {
12     case 1:
13     case 2:
14       return i;
15     }
16   abort();
19 int foo2 (int i)
21   switch (i)
22     {
23     case 1:
24     case 2:
25       return i;
26     }
27   std::abort();
30 int foo3 (int i)
32   switch (i)
33     {
34     case 1:
35     case 2:
36       return i;
37     }
38   exit(1);
41 int foo4 (int i)
43   switch (i)
44     {
45     case 1:
46     case 2:
47       return i;
48     }
49   std::exit(1);
52 void __attribute__ ((__noreturn__)) foo5 ()
54   abort();
57 void __attribute__ ((__noreturn__)) foo6 ()
59   std::abort();
62 void __attribute__ ((__noreturn__)) foo7 ()
64   exit(1);
67 void __attribute__ ((__noreturn__)) foo8 ()
69   std::exit(1);