File: err-switch.ispc

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (74 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download | duplicates (2)
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
// RUN: not %{ispc} --target=host --nowrap --nostdlib %s -o - 2>&1 | FileCheck %s

// CHECK: Error: Case statement value must be a compile-time integer constant

void foo1(float f) {
    switch (f) {
    case 1.5:
        ++f;
    }
}

// CHECK: Error: Duplicate case value "1"

void foo2(float f) {
    switch (f) {
    case 1:
        ++f;
    case 2:
    case 1:
        f = 0;
    }
}

// CHECK: Error: "case" label illegal outside of "switch" statement

void foo3(float f) {
    switch (f) {
    case 1:
        ++f;
    case 2:
        f = 0;
    }
 case 3:
     --f;
}

// CHECK: Error: "default" label illegal outside of "switch" statement

void foo4(float f) {
  default:
     ++f;
    switch (f) {
    case 1:
        ++f;
    case 2:
        f = 0;
    }
}

// CHECK: Error: "default" label illegal outside of "switch" statement

void foo5(float f) {
  default:
     ++f;
    switch (f) {
    case 1:
        ++f;
        continue;
    case 2:
        f = 0;
    }
}

// CHECK: Error: "continue" statement illegal outside of for/while/do/foreach loops

void foo6(float f) {
    switch (f) {
    case 1:
        ++f;
        continue;
    case 2:
        f = 0;
    }
}