summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/switch-duplicate-case.slang
blob: 2d55dc4c85efad0489c796e420b910c20a6a250d (plain)
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
//TEST:SIMPLE(filecheck=CHECK):

// Tests to evaluate the behavior of code blocks within a switch statement. A switch statement with duplicate cases with same values is not allowed and should throw an error

enum class Cases
{
    A,
    B
};

void test1(Cases c)
{
    switch (c)
    {
        case Cases::A: break;
        case Cases::B: break;
        // CHECK: ([[# @LINE+1]]): error 30601: {{.*}}
        case Cases::A: break;
    }
    return;
}

void test2()
{
    switch (0)
    {
        case 1: break;
        case 2: break;
        // CHECK: ([[# @LINE+1]]): error 30601: {{.*}}
        case 1: break;
    }
	return;
}