summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/builtin-noret-2.c
blob: 1103e3d8120e47a08d6c9be7aa83187133a0f9f8 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Test for builtin noreturn attributes when the visible declarations
   are function-local.  Modified from builtin-noret-1.c by Zack Weinberg
   <zack@codesourcery.com>.  */
/* { dg-options "-multiply_defined suppress" { target powerpc-*-darwin* } } */
/* { dg-do link } */
/* { dg-require-weak "" } */

extern void tabort (void);
extern void texit (void);
extern void t_exit (void);
extern void t_Exit (void);

extern void link_failure (void);

int
main (void)
{
  volatile int i = 0;
  extern void exit (int);
  if (i)
    tabort ();
  if (i)
    texit ();
  if (i)
    t_exit ();
  if (i)
    t_Exit ();
  exit (0);
}

void
tabort (void)
{
  extern void abort (void);
  abort ();
  link_failure ();
}

void
texit (void)
{
  extern void exit (int);
  exit (1);
  link_failure ();
}

void
t_exit (void)
{
  extern void _exit (int);
  /* Some non-Unix libcs have _exit, and won't allow it to be re-defined,
     so make it weak.  */
#pragma weak _exit
  _exit (1);
  link_failure ();
}

/* Some non-Unix libcs might not have _exit.  */
/* Some non-Unix libcs have _exit, and won't allow it to be re-defined,
   so make it weak.  */
#pragma weak _exit
void
_exit (int i)
{
  extern void abort (void);
  abort ();
}

void
t_Exit (void)
{
  extern void _Exit (int);
  /* Some libcs have _Exit, and won't allow it to be re-defined,
     so make it weak.  */
#pragma weak _Exit
  _Exit (1);
  link_failure ();
}

/* Some libcs might not have _Exit.  */
/* Some libcs have _Exit, and won't allow it to be re-defined,
   so make it weak.  */
#pragma weak _Exit
void
_Exit (int i)
{
  extern void abort (void);
  abort ();
}