aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/noreturn-7.c
blob: 1d94a7ccea59de76c28e9d8f2057f2d2233db9ad (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
/* PR optimization/13394 */
/* Origin: Carlo Wood <carlo@gcc.gnu.org> */

/* Verify that a bogus "function does return" warning is not issued
   in presence of tail recursion within a noreturn function.  */

/* { dg-do compile } */
/* { dg-options "-O2 -Wreturn-type -Wmissing-noreturn" } */


void f(void) __attribute__ ((__noreturn__));
void _exit(int status) __attribute__ ((__noreturn__));

int z = 0;

void g()
{
  if (++z > 10)
    _exit(0);
  g();
}             /* { dg-warning "possible candidate" } */

void f()
{
  if (++z > 10)
    _exit(0);
  f();
}             /* { dg-bogus "does return" } */

int h()
{
  if (++z > 10)
    _exit(0);
  return h();
}             /* { dg-bogus "end of non-void function" } */

int k()
{
  if (++z > 10)
    _exit(0);
  k();
}             /* { dg-warning "end of non-void function" } */