llvm-project/clang/test/OpenMP/taskyield_messages.cpp
Aaron Ballman 8bd06d5b65
[C23] Complete support for WG14 N2508 (#71398)
In Clang 16, we implemented the ability to add a label at the end of a
compound statement. These changes complete the implementation by
allowing a label to be followed by a declaration in C.

Note, this seems to have fixed an issue with some OpenMP stand-alone
directives not being properly diagnosed as per:
https://www.openmp.org/spec-html/5.1/openmpsu19.html#x34-330002.1.3
(The same requirement exists in OpenMP 5.2 as well.)
2023-11-20 10:52:11 -05:00

119 lines
3.7 KiB
C++

// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
template <class T>
T tmain(T argc) {
#pragma omp taskyield allocate(argc) // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp taskyield'}}
;
#pragma omp taskyield untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp taskyield'}}
#pragma omp taskyield unknown // expected-warning {{extra tokens at the end of '#pragma omp taskyield' are ignored}}
if (argc)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
if (argc) {
#pragma omp taskyield
}
while (argc)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
while (argc) {
#pragma omp taskyield
}
do
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
while (argc)
;
do {
#pragma omp taskyield
} while (argc);
switch (argc)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
switch (argc)
case 1:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
switch (argc)
case 1: {
#pragma omp taskyield
}
switch (argc) {
#pragma omp taskyield
case 1:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
break;
default: {
#pragma omp taskyield
} break;
}
for (;;)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
for (;;) {
#pragma omp taskyield
}
label:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
label1 : {
#pragma omp taskyield
}
if (1)
label2:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
return T();
}
int main(int argc, char **argv) {
#pragma omp taskyield
;
#pragma omp taskyield untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp taskyield'}}
#pragma omp taskyield unknown // expected-warning {{extra tokens at the end of '#pragma omp taskyield' are ignored}}
if (argc)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
if (argc) {
#pragma omp taskyield
}
while (argc)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
while (argc) {
#pragma omp taskyield
}
do
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
while (argc)
;
do {
#pragma omp taskyield
} while (argc);
switch (argc)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
switch (argc)
case 1:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
switch (argc)
case 1: {
#pragma omp taskyield
}
switch (argc) {
#pragma omp taskyield
case 1:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
break;
default: {
#pragma omp taskyield
} break;
}
for (;;)
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
for (;;) {
#pragma omp taskyield
}
label:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
label1 : {
#pragma omp taskyield
}
if (1)
label2:
#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
return tmain(argc);
}