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" } 5 6 #include <cstdlib> 7 foo1(int i)8int foo1 (int i) 9 { 10 switch (i) 11 { 12 case 1: 13 case 2: 14 return i; 15 } 16 abort(); 17 } 18 foo2(int i)19int foo2 (int i) 20 { 21 switch (i) 22 { 23 case 1: 24 case 2: 25 return i; 26 } 27 std::abort(); 28 } 29 foo3(int i)30int foo3 (int i) 31 { 32 switch (i) 33 { 34 case 1: 35 case 2: 36 return i; 37 } 38 exit(1); 39 } 40 foo4(int i)41int foo4 (int i) 42 { 43 switch (i) 44 { 45 case 1: 46 case 2: 47 return i; 48 } 49 std::exit(1); 50 } 51 foo5()52void __attribute__ ((__noreturn__)) foo5 () 53 { 54 abort(); 55 } 56 foo6()57void __attribute__ ((__noreturn__)) foo6 () 58 { 59 std::abort(); 60 } 61 foo7()62void __attribute__ ((__noreturn__)) foo7 () 63 { 64 exit(1); 65 } 66 foo8()67void __attribute__ ((__noreturn__)) foo8 () 68 { 69 std::exit(1); 70 } 71 72