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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [switch-warn-1.c] - Blame information for rev 867

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O0" } */
3
 
4
extern void abort (void);
5
extern void exit (int);
6
 
7
/* Check that out-of-bounds case warnings work in the case that the
8
   testing expression is promoted.  */
9
int
10
foo1 (unsigned char i)
11
{
12
  switch (i)
13
    {
14
    case -1:   /* { dg-warning "case label value is less than minimum value for type" } */
15
      return 1;
16
    case 256:  /* { dg-warning "case label value exceeds maximum value for type" } */
17
      return 2;
18
    default:
19
      return 3;
20
    }
21
}
22
 
23
/* Like above, but for case ranges that need to be satured.  */
24
int
25
foo2 (unsigned char i)
26
{
27
  switch (i)
28
    {
29
    case -1 ... 1:   /* { dg-warning "lower value in case label range less than minimum value for type" } */
30
      return 1;
31
    case 254 ... 256:  /* { dg-warning "upper value in case label range exceeds maximum value for type" } */
32
      return 2;
33
    default:
34
      return 3;
35
    }
36
}
37
 
38
int
39
main (void)
40
{
41
  if (foo1 (10) != 3)
42
    abort ();
43
  if (foo2 (10) != 3)
44
    abort ();
45
  exit (0);
46
}
47
 

powered by: WebSVN 2.1.0

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