OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [c1x-noreturn-2.c] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test C1X _Noreturn.  Test valid code using stdnoreturn.h.  */
2
/* { dg-do run } */
3
/* { dg-options "-std=c1x -pedantic-errors" } */
4
 
5
#include <stdnoreturn.h>
6
 
7
extern int strcmp (const char *, const char *);
8
 
9
noreturn void exit (int);
10
noreturn void abort (void);
11
 
12
noreturn int f1 (void);
13
 
14
noreturn void f2 (void);
15
 
16
static void noreturn f3 (void) { exit (0); }
17
 
18
/* Returning from a noreturn function is undefined at runtime, not a
19
   constraint violation, but recommended practice is to diagnose if
20
   such a return appears possible.  */
21
 
22
noreturn int
23
f4 (void)
24
{
25
  return 1; /* { dg-warning "has a 'return' statement" } */
26
  /* { dg-warning "does return" "second warning" { target *-*-* } 25 } */
27
}
28
 
29
noreturn void
30
f5 (void)
31
{
32
  return; /* { dg-warning "has a 'return' statement" } */
33
  /* { dg-warning "does return" "second warning" { target *-*-* } 32 } */
34
}
35
 
36
noreturn void
37
f6 (void)
38
{
39
} /* { dg-warning "does return" } */
40
 
41
noreturn void
42
f7 (int a)
43
{
44
  if (a)
45
    exit (0);
46
} /* { dg-warning "does return" } */
47
 
48
/* Declarations need not all have noreturn.  */
49
 
50
void f2 (void);
51
 
52
void f8 (void);
53
noreturn void f8 (void);
54
 
55
/* Duplicate noreturn is OK.  */
56
noreturn noreturn void noreturn f9 (void);
57
 
58
/* noreturn does not affect type compatibility.  */
59
 
60
void (*fp) (void) = f5;
61
 
62
#ifndef noreturn
63
#error "noreturn not defined"
64
#endif
65
 
66
#define str(x) #x
67
#define xstr(x) str(x)
68
 
69
const char *s = xstr(noreturn);
70
 
71
int
72
main (void)
73
{
74
  if (strcmp (s, "_Noreturn") != 0)
75
    abort ();
76
  exit (0);
77
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.