[OPENMP] Added several test cases for clauses 'ordered' and 'nowait': if there are more than one 'nowait' or 'ordered' clause an error message is expected.

llvm-svn: 213496
This commit is contained in:
Alexey Bataev 2014-07-21 02:45:36 +00:00
parent 601957fa23
commit 4c904adf7c
5 changed files with 82 additions and 42 deletions

View File

@ -678,3 +678,17 @@ void test_loop_firstprivate_lastprivate() {
for (int i = 0; i < 16; ++i)
;
}
void test_ordered() {
#pragma omp parallel
#pragma omp for ordered ordered // expected-error {{directive '#pragma omp for' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
}
void test_nowait() {
#pragma omp parallel
#pragma omp for nowait nowait // expected-error {{directive '#pragma omp for' cannot contain more than one 'nowait' clause}}
for (int i = 0; i < 16; ++i)
;
}

View File

@ -6,65 +6,81 @@ void foo() {
#pragma omp parallel for // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}}
int main(int argc, char **argv) {
#pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for [ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for ] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for ) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for
for(int i = 0; i < argc; ++i) foo();
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
#pragma omp parallel for unknown()
for(int i = 0; i < argc; ++i) foo();
L1:
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for
for(int i = 0; i < argc; ++i) foo();
#pragma omp parallel for
for(int i = 0; i < argc; ++i)
{
#pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for
for (int i = 0; i < argc; ++i)
foo();
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
#pragma omp parallel for unknown()
for (int i = 0; i < argc; ++i)
foo();
L1:
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for
for (int i = 0; i < argc; ++i)
foo();
#pragma omp parallel for
for (int i = 0; i < argc; ++i) {
goto L1; // expected-error {{use of undeclared label 'L1'}}
argc++;
}
for (int i = 0; i < 10; ++i) {
switch(argc) {
case (0):
#pragma omp parallel for
for(int i = 0; i < argc; ++i)
{
switch (argc) {
case (0):
#pragma omp parallel for
for (int i = 0; i < argc; ++i) {
foo();
break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
continue;
}
default:
break;
default:
break;
}
}
#pragma omp parallel for default(none)
#pragma omp parallel for default(none)
for (int i = 0; i < 10; ++i)
++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
goto L2; // expected-error {{use of undeclared label 'L2'}}
#pragma omp parallel for
for(int i = 0; i < argc; ++i) L2:foo();
#pragma omp parallel for
for(int i = 0; i < argc; ++i)
{
#pragma omp parallel for
for (int i = 0; i < argc; ++i)
L2:
foo();
#pragma omp parallel for
for (int i = 0; i < argc; ++i) {
return 1; // expected-error {{cannot return from OpenMP region}}
}
[[]] // expected-error {{an attribute list cannot appear here}}
#pragma omp parallel for
for (int n = 0; n < 100; ++n) {}
#pragma omp parallel for
for (int n = 0; n < 100; ++n) {
}
return 0;
}
void test_ordered() {
#pragma omp parallel for ordered ordered // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
}

View File

@ -83,4 +83,3 @@ int main(int argc, char **argv) {
return 0;
}

View File

@ -24,7 +24,6 @@ void test_no_clause() {
foo();
foo(); // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}
}
}
void test_branch_protected_scope() {
@ -291,3 +290,10 @@ void test_firstprivate() {
}
}
void test_nowait() {
#pragma omp parallel
#pragma omp sections nowait nowait // expected-error {{directive '#pragma omp sections' cannot contain more than one 'nowait' clause}}
{
;
}
}

View File

@ -149,3 +149,8 @@ void test_firstprivate() {
foo();
}
void test_nowait() {
#pragma omp single nowait nowait // expected-error {{directive '#pragma omp single' cannot contain more than one 'nowait' clause}}
for (int i = 0; i < 16; ++i)
;
}