Skip to content

Commit 2d61979

Browse files
committed
[OpenACC] Add dependent test for break/continue compute construct diag
I discovered while debugging something else that this could possibly cause an assert if I'm not careful with followup patches, so add the tests.
1 parent 6afda56 commit 2d61979

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

clang/test/SemaOpenACC/no-branch-in-out.cpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,100 @@ void ReturnTest() {
1515
}
1616
}
1717
}
18+
19+
template<typename T>
20+
void BreakContinue() {
21+
22+
#pragma acc parallel
23+
for(int i =0; i < 5; ++i) {
24+
switch(i) {
25+
case 0:
26+
break; // leaves switch, not 'for'.
27+
default:
28+
i +=2;
29+
break;
30+
}
31+
if (i == 2)
32+
continue;
33+
34+
break; // expected-error{{invalid branch out of OpenACC Compute Construct}}
35+
}
36+
37+
int j;
38+
switch(j) {
39+
case 0:
40+
#pragma acc parallel
41+
{
42+
break; // expected-error{{invalid branch out of OpenACC Compute Construct}}
43+
}
44+
case 1:
45+
#pragma acc parallel
46+
{
47+
}
48+
break;
49+
}
50+
51+
#pragma acc parallel
52+
for(int i = 0; i < 5; ++i) {
53+
if (i > 1)
54+
break; // expected-error{{invalid branch out of OpenACC Compute Construct}}
55+
}
56+
57+
#pragma acc parallel
58+
switch(j) {
59+
case 1:
60+
break;
61+
}
62+
63+
#pragma acc parallel
64+
{
65+
for(int i = 1; i < 100; i++) {
66+
if (i > 4)
67+
break;
68+
}
69+
}
70+
71+
for (int i =0; i < 5; ++i) {
72+
#pragma acc parallel
73+
{
74+
continue; // expected-error{{invalid branch out of OpenACC Compute Construct}}
75+
}
76+
}
77+
78+
#pragma acc parallel
79+
for (int i =0; i < 5; ++i) {
80+
continue;
81+
}
82+
83+
#pragma acc parallel
84+
for (int i =0; i < 5; ++i) {
85+
{
86+
continue;
87+
}
88+
}
89+
90+
for (int i =0; i < 5; ++i) {
91+
#pragma acc parallel
92+
{
93+
break; // expected-error{{invalid branch out of OpenACC Compute Construct}}
94+
}
95+
}
96+
97+
#pragma acc parallel
98+
while (j) {
99+
--j;
100+
if (j > 4)
101+
break; // expected-error{{invalid branch out of OpenACC Compute Construct}}
102+
}
103+
104+
#pragma acc parallel
105+
do {
106+
--j;
107+
if (j > 4)
108+
break; // expected-error{{invalid branch out of OpenACC Compute Construct}}
109+
} while (j );
110+
}
111+
112+
void Instantiate() {
113+
BreakContinue<int>();
114+
}

0 commit comments

Comments
 (0)