aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/noreturn-1.c
blob: a3796783a3e24e2c5e5ab34aa3015b76a1519f1c (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
/* Check for various valid and erroneous "noreturn" cases. */
/* { dg-do compile } */
/* { dg-options "-O2 -Wmissing-noreturn" } */

extern void exit (int);

extern void foo1(void) __attribute__ ((__noreturn__));
void
foo1(void)
{
} /* { dg-warning "'noreturn' function does return" "detect falling off end of noreturn" } */

extern void foo2(void) __attribute__ ((__noreturn__));
void
foo2(void)
{
  exit(0);
} /* { dg-bogus "warning:" "this function should not get any warnings" } */

extern void foo3(void);
void
foo3(void)
{
} /* { dg-bogus "warning:" "this function should not get any warnings" } */

extern void foo4(void);
void
foo4(void) /* { dg-warning "candidate for attribute 'noreturn'" "detect noreturn candidate" } */
{
  exit(0);
}

extern void foo5(void) __attribute__ ((__noreturn__));
void
foo5(void)
{
  return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */
}         /* { dg-warning "function does return" "detect return from noreturn" { target c } 37 } */

extern void foo6(void);
void
foo6(void)
{
  return;
} /* { dg-bogus "warning:" "this function should not get any warnings" } */

extern void foo7(void);
void
foo7(void)
{
  foo6();
} /* { dg-bogus "warning:" "this function should not get any warnings" } */

extern void foo8(void) __attribute__ ((__noreturn__));
void
foo8(void)
{
  foo7();
} /* { dg-warning "'noreturn' function does return" "detect return from tail call" } */