OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [switch-5.c] - Blame information for rev 645

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

Line No. Rev Author Line
1 149 jeremybenn
/* Test diagnostics for switch statements and labels therein.  Test
2
   with no special options.  */
3
/* Origin: Joseph Myers <joseph@codesourcery.com> */
4
/* { dg-do compile } */
5
/* { dg-options "" } */
6
 
7
void
8
f (int a, double d, void *p)
9
{
10
  switch (d) /* { dg-error "error: switch quantity not an integer" } */
11
    {
12
    }
13
  switch (p) /* { dg-error "error: switch quantity not an integer" } */
14
    {
15
    }
16
  switch (a)
17
    {
18
    case (void *)0: ; /* { dg-error "error: pointers are not permitted as case values" } */
19
    }
20
  switch (a)
21
    {
22
    case (double)0: ; /* { dg-error "error: case label does not reduce to an integer constant" } */
23
    }
24
  switch (a)
25
    {
26
    case (char)0: ;
27
    }
28
  switch (a)
29
    {
30
    case 0 ... 0: ;
31
    }
32
  switch (a)
33
    {
34
    case 0 ... -1: ; /* { dg-warning "warning: empty range specified" } */
35
    }
36
  switch (a)
37
    {
38
    case 0 ... -2: ; /* { dg-warning "warning: empty range specified" } */
39
    }
40
  switch (a)
41
    {
42
    case 0:
43
    default: /* { dg-error "error: this is the first default label" } */
44
    case 1:
45
    default: ; /* { dg-error "error: multiple default labels in one switch" } */
46
    }
47
  switch (a)
48
    {
49
    case 0: /* { dg-error "error: previously used here" } */
50
    case 1:
51
    case 0: ; /* { dg-error "error: duplicate case value" } */
52
    }
53
 case 1: ; /* { dg-error "error: case label not within a switch statement" } */
54
 default: ; /* { dg-error "error: 'default' label not within a switch statement" } */
55
   break; /* { dg-error "error: break statement not within loop or switch" } */
56
   continue; /* { dg-error "error: continue statement not within a loop" } */
57
   switch (a)
58
     {
59
     case a: ; /* { dg-error "error: case label does not reduce to an integer constant" } */
60
     }
61
   switch (a)
62
     {
63
     case 0: /* { dg-error "error: this is the first entry overlapping that value" } */
64
     case -1 ... 1: /* { dg-error "error: duplicate \\(or overlapping\\) case value" } */
65
     case 2 ... 3: /* { dg-error "error: previously used here" } */
66
     case 2: /* { dg-error "error: duplicate case value" } */
67
     case 4 ... 7: /* { dg-error "error: this is the first entry overlapping that value" } */
68
     case 6 ... 9: ; /* { dg-error "error: duplicate \\(or overlapping\\) case value" } */
69
     }
70
   switch (a)
71
     {
72
     case 0:
73
       continue; /* { dg-error "error: continue statement not within a loop" } */
74
     }
75
}

powered by: WebSVN 2.1.0

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