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

Subversion Repositories openrisc_me

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

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

Line No. Rev Author Line
1 298 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 "switch quantity not an integer" } */
11
    {
12
    }
13
  switch (p) /* { dg-error "switch quantity not an integer" } */
14
    {
15
    }
16
  switch (a)
17
    {
18
    case (void *)0: ; /* { dg-error "pointers are not permitted as case values" } */
19
    }
20
  switch (a)
21
    {
22
    case (double)0: ; /* { dg-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 "empty range specified" } */
35
    }
36
  switch (a)
37
    {
38
    case 0 ... -2: ; /* { dg-warning "empty range specified" } */
39
    }
40
  switch (a)
41
    {
42
    case 0:
43
    default: /* { dg-error "this is the first default label" } */
44
    case 1:
45
    default: ; /* { dg-error "multiple default labels in one switch" } */
46
    }
47
  switch (a)
48
    {
49
    case 0: /* { dg-error "previously used here" } */
50
    case 1:
51
    case 0: ; /* { dg-error "duplicate case value" } */
52
    }
53
 case 1: ; /* { dg-error "case label not within a switch statement" } */
54
 default: ; /* { dg-error "'default' label not within a switch statement" } */
55
   break; /* { dg-error "break statement not within loop or switch" } */
56
   continue; /* { dg-error "continue statement not within a loop" } */
57
   switch (a)
58
     {
59
     case a: ; /* { dg-error "case label does not reduce to an integer constant" } */
60
     }
61
   switch (a)
62
     {
63
     case 0: /* { dg-error "this is the first entry overlapping that value" } */
64
     case -1 ... 1: /* { dg-error "duplicate \\(or overlapping\\) case value" } */
65
     case 2 ... 3: /* { dg-error "previously used here" } */
66
     case 2: /* { dg-error "duplicate case value" } */
67
     case 4 ... 7: /* { dg-error "this is the first entry overlapping that value" } */
68
     case 6 ... 9: ; /* { dg-error "duplicate \\(or overlapping\\) case value" } */
69
     }
70
   switch (a)
71
     {
72
     case 0:
73
       continue; /* { dg-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.