Skip to content

Commit 5d45b08

Browse files
committed
Retained original behaviour for OMP < 60 and updated LIT tests
1 parent 0baf20d commit 5d45b08

15 files changed

+195
-122
lines changed

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,6 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
31643164
case OMPC_simdlen:
31653165
case OMPC_collapse:
31663166
case OMPC_ordered:
3167-
case OMPC_nowait:
31683167
case OMPC_priority:
31693168
case OMPC_grainsize:
31703169
case OMPC_num_tasks:
@@ -3213,8 +3212,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
32133212
ErrorFound = true;
32143213
}
32153214

3216-
if ((CKind == OMPC_ordered || CKind == OMPC_nowait ||
3217-
CKind == OMPC_partial) &&
3215+
if ((CKind == OMPC_ordered || CKind == OMPC_partial) &&
32183216
PP.LookAhead(/*N=*/0).isNot(tok::l_paren))
32193217
Clause = ParseOpenMPClause(CKind, WrongDirective);
32203218
else if (CKind == OMPC_grainsize || CKind == OMPC_num_tasks ||
@@ -3279,6 +3277,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
32793277
case OMPC_holds:
32803278
Clause = ParseOpenMPSingleExprClause(CKind, WrongDirective);
32813279
break;
3280+
case OMPC_nowait:
32823281
case OMPC_untied:
32833282
case OMPC_mergeable:
32843283
case OMPC_read:
@@ -3312,7 +3311,11 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
33123311
ErrorFound = true;
33133312
}
33143313

3315-
Clause = ParseOpenMPClause(CKind, WrongDirective);
3314+
if (CKind == OMPC_nowait &&
3315+
PP.LookAhead(/*N=*/0).is(tok::l_paren) && getLangOpts().OpenMP >= 60)
3316+
Clause = ParseOpenMPSingleExprClause(CKind, WrongDirective);
3317+
else
3318+
Clause = ParseOpenMPClause(CKind, WrongDirective);
33163319
break;
33173320
case OMPC_self_maps:
33183321
// OpenMP [6.0, self_maps clause]
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
1+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=45 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
2+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
3+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
4+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
25

3-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
6+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=45 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
7+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
8+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
9+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
410

511
int main(int argc, char **argv) {
612
int i;
@@ -13,27 +19,27 @@ int main(int argc, char **argv) {
1319
{}
1420
#pragma omp target enter nowait data map(to: i) // expected-error {{expected an OpenMP directive}}
1521
{}
16-
#pragma omp target enter data nowait() map(to: i) // expected-error {{expected expression}}
22+
#pragma omp target enter data map(to: i) nowait() // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}} omp-60-and-later-error {{expected expression}}
1723
{}
18-
#pragma omp target enter data map(to: i) nowait( // expected-error {{expected expression}} // expected-error {{expected ')'}} // expected-note {{to match this '('}}
24+
#pragma omp target enter data map(to: i) nowait( // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}} omp-60-and-later-error {{expected expression}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
1925
{}
20-
#pragma omp target enter data map(to: i) nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
26+
#pragma omp target enter data map(to: i) nowait (argc)) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}} omp-60-and-later-warning {{extra tokens at the end of '#pragma omp target_enter_data' are ignored}}
2127
{}
2228
#pragma omp target enter data map(to: i) nowait device (-10u)
2329
{}
24-
#pragma omp target enter data map(to: i) nowait (3.14) device (-10u)
30+
#pragma omp target enter data map(to: i) nowait (3.14) device (-10u) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
2531
{}
26-
#pragma omp target enter data map(to: i) nowait (argc>> i)
32+
#pragma omp target enter data map(to: i) nowait (argc>> i) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
2733
{}
28-
#pragma omp target enter data map(to: i) nowait (argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
34+
#pragma omp target enter data map(to: i) nowait (argv[1] = 2) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
2935
{}
30-
#pragma omp target enter data map(to: i) nowait (argc > 0 ? argv[1] : argv[2])
36+
#pragma omp target enter data map(to: i) nowait (argc > 0 ? argv[1] : argv[2]) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
3137
{}
32-
#pragma omp target enter data map(to: i) nowait (S1) // expected-error {{use of undeclared identifier 'S1'}}
38+
#pragma omp target enter data map(to: i) nowait (S1) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}} omp-60-and-later-error {{use of undeclared identifier 'S1'}}
3339
{}
34-
#pragma omp target enter data map(to: i) nowait nowait // expected-error {{directive '#pragma omp target enter data' cannot contain more than one 'nowait' clause}}
40+
#pragma omp target enter data map(to: i) nowait nowait // omp-52-and-earlier-error {{directive '#pragma omp target enter data' cannot contain more than one 'nowait' clause}} omp-60-and-later-error {{directive '#pragma omp target_enter_data' cannot contain more than one 'nowait' clause}}
3541
{}
36-
#pragma omp target enter data nowait map(to: i) nowait // expected-error {{directive '#pragma omp target enter data' cannot contain more than one 'nowait' clause}}
42+
#pragma omp target enter data nowait map(to: i) nowait // omp-52-and-earlier-error {{directive '#pragma omp target enter data' cannot contain more than one 'nowait' clause}} omp-60-and-later-error {{directive '#pragma omp target_enter_data' cannot contain more than one 'nowait' clause}}
3743
{}
3844
return 0;
3945
}
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
1+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
2+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
3+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
24

3-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
5+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
6+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
7+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
48

59
int main(int argc, char **argv) {
610
int i;
711

812
#pragma omp nowait target exit data map(from: i) // expected-error {{expected an OpenMP directive}}
913
#pragma omp target nowait exit data map(from: i) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
1014
#pragma omp target exit nowait data map(from: i) // expected-error {{expected an OpenMP directive}}
11-
#pragma omp target exit data nowait() map(from: i) // expected-error {{expected expression}}
12-
#pragma omp target exit data map(from: i) nowait( // expected-error {{expected expression}} // expected-error {{expected ')'}} // expected-note {{to match this '('}}
13-
#pragma omp target exit data map(from: i) nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
15+
#pragma omp target exit data map(from: i) nowait() // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}} omp-60-and-later-error {{expected expression}}
16+
#pragma omp target exit data map(from: i) nowait( // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}} omp-60-and-later-error {{expected expression}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
17+
#pragma omp target exit data map(from: i) nowait (argc)) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}} omp-60-and-later-warning {{extra tokens at the end of '#pragma omp target_exit_data' are ignored}}
1418
#pragma omp target exit data map(from: i) nowait device (-10u)
15-
#pragma omp target exit data map(from: i) nowait (3.14) device (-10u)
16-
#pragma omp target exit data map(from: i) nowait (argc>> i)
17-
#pragma omp target exit data map(from: i) nowait (argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
18-
#pragma omp target exit data map(from: i) nowait (argc > 0 ? argv[1] : argv[2])
19-
#pragma omp target exit data map(from: i) nowait (S1) // expected-error {{use of undeclared identifier 'S1'}}
20-
#pragma omp target exit data map(from: i) nowait nowait // expected-error {{directive '#pragma omp target exit data' cannot contain more than one 'nowait' clause}}
21-
#pragma omp target exit data nowait map(from: i) nowait // expected-error {{directive '#pragma omp target exit data' cannot contain more than one 'nowait' clause}}
19+
#pragma omp target exit data map(from: i) nowait (3.14) device (-10u) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
20+
#pragma omp target exit data map(from: i) nowait (argc>> i) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
21+
#pragma omp target exit data map(from: i) nowait (argv[1] = 2) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
22+
#pragma omp target exit data map(from: i) nowait (argc > 0 ? argv[1] : argv[2]) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
23+
#pragma omp target exit data map(from: i) nowait (S1) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}} omp-60-and-later-error {{use of undeclared identifier 'S1'}}
24+
#pragma omp target exit data map(from: i) nowait nowait // omp-52-and-earlier-error {{directive '#pragma omp target exit data' cannot contain more than one 'nowait' clause}} omp-60-and-later-error {{directive '#pragma omp target_exit_data' cannot contain more than one 'nowait' clause}}
25+
#pragma omp target exit data nowait map(from: i) nowait // omp-52-and-earlier-error {{directive '#pragma omp target exit data' cannot contain more than one 'nowait' clause}} omp-60-and-later-error {{directive '#pragma omp target_exit_data' cannot contain more than one 'nowait' clause}}
2226
return 0;
2327
}

clang/test/OpenMP/target_nowait_messages.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
1+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=45 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
2+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
3+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
4+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
25

3-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
6+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=45 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
7+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
8+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
9+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
410

511
void foo() {
612
}
713

814
int main(int argc, char **argv) {
915
int i;
10-
#pragma omp target nowait(// expected-error {{expected expression}} // expected-error {{expected ')'}} // expected-note {{to match this '('}}
16+
#pragma omp target nowait( // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target' are ignored}} omp-60-and-later-error {{expected expression}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
1117
foo();
1218
#pragma omp target nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
1319
foo();
1420
#pragma omp target nowait device (-10u)
1521
foo();
16-
#pragma omp target nowait (3.14) device (-10u)
22+
#pragma omp target nowait (3.14) device (-10u) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
1723
foo();
18-
#pragma omp target nowait (argc>> i)
24+
#pragma omp target nowait (argc>> i) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
1925
foo();
20-
#pragma omp target nowait (argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
26+
#pragma omp target nowait (argv[1] = 2) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target' are ignored}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
2127
foo();
22-
#pragma omp target nowait (argc > 0 ? argv[1] : argv[2])
28+
#pragma omp target nowait (argc > 0 ? argv[1] : argv[2]) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
2329
foo();
24-
#pragma omp target nowait (S1) // expected-error {{use of undeclared identifier 'S1'}}
30+
#pragma omp target nowait (S1) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target' are ignored}} omp-60-and-later-error {{use of undeclared identifier 'S1'}}
2531
foo();
2632

2733
return 0;

clang/test/OpenMP/target_parallel_for_nowait_messages.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
1+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
2+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
3+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
24

3-
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
5+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=51 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
6+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=52 -verify=expected,omp-52-and-earlier -ferror-limit 100 -o - %s -Wuninitialized
7+
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fopenmp-simd -fopenmp-version=60 -verify=expected,omp-60-and-later -ferror-limit 100 -o - %s -Wuninitialized
48

59
void foo() {
610
}
711

812
int main(int argc, char **argv) {
913
int i, z;
10-
#pragma omp target parallel for nowait( // expected-error {{expected expression}} // expected-error {{expected ')'}} // expected-note {{to match this '('}}
14+
#pragma omp target parallel for nowait( // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} omp-60-and-later-error {{expected expression}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
1115
for (i = 0; i < argc; ++i) foo();
1216
#pragma omp target parallel for nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
1317
for (i = 0; i < argc; ++i) foo();
1418
#pragma omp target parallel for nowait device (-10u)
1519
for (i = 0; i < argc; ++i) foo();
16-
#pragma omp target parallel for nowait (3.14) device (-10u)
20+
#pragma omp target parallel for nowait (3.14) device (-10u) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
1721
for (i = 0; i < argc; ++i) foo();
18-
#pragma omp target parallel for nowait (argc>> z)
22+
#pragma omp target parallel for nowait (argc>> z) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
1923
for (i = 0; i < argc; ++i) foo();
20-
#pragma omp target parallel for nowait (argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
24+
#pragma omp target parallel for nowait (argv[1] = 2) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} omp-60-and-later-error {{expected ')'}} omp-60-and-later-note {{to match this '('}}
2125
for (i = 0; i < argc; ++i) foo();
22-
#pragma omp target parallel for nowait (argc > 0 ? argv[1] : argv[2])
26+
#pragma omp target parallel for nowait (argc > 0 ? argv[1] : argv[2]) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
2327
for (i = 0; i < argc; ++i) foo();
24-
#pragma omp target parallel for nowait (S1) // expected-error {{use of undeclared identifier 'S1'}}
28+
#pragma omp target parallel for nowait (S1) // omp-52-and-earlier-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} omp-60-and-later-error {{use of undeclared identifier 'S1'}}
2529
for (i = 0; i < argc; ++i) foo();
2630

2731
return 0;

0 commit comments

Comments
 (0)