[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #125648)
Urvi Rav via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 23:19:44 PST 2025
https://github.com/ravurvi20 updated https://github.com/llvm/llvm-project/pull/125648
>From 189dd3cc2230ea5752969f02f119b6ee30e3df69 Mon Sep 17 00:00:00 2001
From: Urvi Rav <urvi.rav20 at gmail.com>
Date: Tue, 4 Feb 2025 01:35:41 -0600
Subject: [PATCH 1/6] default clause replaced by otherwise clause for
metadirective
---
.../clang/Basic/DiagnosticParseKinds.td | 4 ++++
clang/lib/Parse/ParseOpenMP.cpp | 15 ++++++++++++++
clang/test/OpenMP/metadirective_ast_print.c | 20 +++++++++----------
.../metadirective_device_arch_codegen.cpp | 2 +-
.../metadirective_device_isa_codegen.cpp | 4 ++--
...etadirective_device_isa_codegen_amdgcn.cpp | 4 ++--
.../metadirective_device_kind_codegen.c | 2 +-
.../metadirective_device_kind_codegen.cpp | 2 +-
clang/test/OpenMP/metadirective_empty.cpp | 4 ++--
.../metadirective_implementation_codegen.c | 12 +++++------
.../metadirective_implementation_codegen.cpp | 12 +++++------
clang/test/OpenMP/metadirective_messages.cpp | 12 +++++++----
12 files changed, 58 insertions(+), 35 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c513dab810d1f..4b8449e9ee9b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1657,6 +1657,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">;
def err_omp_missing_comma : Error< "missing ',' after %0">;
def err_omp_expected_context_selector
: Error<"expected valid context selector in %0">;
+def err_omp_unknown_clause
+ : Error<"unknown clause '%0' in %1">;
+def warn_omp_default_deprecated : Warning<"'default' clause for"
+ " 'metadirective' is deprecated; use 'otherwise' instead">, InGroup<Deprecated>;
def err_omp_requires_out_inout_depend_type : Error<
"reserved locator 'omp_all_memory' requires 'out' or 'inout' "
"dependency types">;
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 89b83938f352d..673806ef28b9f 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2743,6 +2743,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
OpenMPClauseKind CKind = Tok.isAnnotation()
? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
+ // Check if the clause is unrecognized.
+ if (CKind == OMPC_unknown) {
+ Diag(Tok, diag::err_omp_unknown_clause)
+ << PP.getSpelling(Tok) << "metadirective";
+ return Directive;
+ }
+ if(CKind == OMPC_default) {
+ Diag(Tok, diag::warn_omp_default_deprecated);
+ }
SourceLocation Loc = ConsumeToken();
// Parse '('.
@@ -2769,6 +2778,12 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
return Directive;
}
}
+ if (CKind == OMPC_otherwise) {
+ // Check for 'otherwise' keyword.
+ if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->getName() == "otherwise") {
+ ConsumeToken(); // Consume 'otherwise'
+ }
+ }
// Skip Directive for now. We will parse directive in the second iteration
int paren = 0;
while (Tok.isNot(tok::r_paren) || paren != 0) {
diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c
index d9ff7e7645216..28efaac594942 100644
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ b/clang/test/OpenMP/metadirective_ast_print.c
@@ -15,18 +15,18 @@ void bar(void);
#define N 10
void foo(void) {
#pragma omp metadirective when(device = {kind(cpu)} \
- : parallel) default()
+ : parallel) otherwise()
bar();
#pragma omp metadirective when(implementation = {vendor(score(0) \
: llvm)}, \
device = {kind(cpu)} \
- : parallel) default(target teams)
+ : parallel) otherwise(target teams)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
: target teams) when(implementation = {vendor(llvm)} \
- : parallel) default()
+ : parallel) otherwise()
bar();
-#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
+#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \
: llvm)}, \
device = {kind(cpu, host)} \
: parallel)
@@ -40,15 +40,15 @@ void foo(void) {
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_none)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
@@ -64,17 +64,17 @@ void foo(void) {
#pragma omp metadirective when(device={arch("amdgcn")}: \
teams distribute parallel for)\
- default(parallel for)
+ otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : nothing) default(parallel for)
+ : nothing) otherwise(parallel for)
for (int i = 0; i < 16; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) default(nothing)
+ : parallel) otherwise(nothing)
for (int i = 0; i < 16; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_device_arch_codegen.cpp b/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
index eecae310d0a77..c44337b33d5b3 100644
--- a/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
@@ -27,7 +27,7 @@ int metadirective1() {
{
#pragma omp metadirective \
when(device={arch("amdgcn")}: teams distribute parallel for) \
- default(parallel for)
+ otherwise(parallel for)
for (int i = 0; i < N; i++) {
#pragma omp atomic write
diff --git a/clang/test/OpenMP/metadirective_device_isa_codegen.cpp b/clang/test/OpenMP/metadirective_device_isa_codegen.cpp
index 1d098063101d7..1b9829f7a56ce 100644
--- a/clang/test/OpenMP/metadirective_device_isa_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_device_isa_codegen.cpp
@@ -8,7 +8,7 @@ void bar();
void x86_64_device_isa_selected() {
#pragma omp metadirective when(device = {isa("sse2")} \
- : parallel) default(single)
+ : parallel) otherwise(single)
bar();
}
// CHECK-LABEL: void @_Z26x86_64_device_isa_selectedv()
@@ -21,7 +21,7 @@ void x86_64_device_isa_selected() {
void x86_64_device_isa_not_selected() {
#pragma omp metadirective when(device = {isa("some-unsupported-feature")} \
- : parallel) default(single)
+ : parallel) otherwise(single)
bar();
}
// CHECK-LABEL: void @_Z30x86_64_device_isa_not_selectedv()
diff --git a/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp b/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
index cbb75c4a68376..c2c7b72a8469f 100644
--- a/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
+++ b/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
@@ -15,7 +15,7 @@ int amdgcn_device_isa_selected() {
{
#pragma omp metadirective \
when(device = {isa("dpp")} \
- : parallel) default(single)
+ : parallel) otherwise(single)
threadCount++;
}
@@ -38,7 +38,7 @@ int amdgcn_device_isa_not_selected() {
when(device = {isa("sse")} \
: parallel) \
when(device = {isa("another-unsupported-gpu-feature")} \
- : parallel) default(single)
+ : parallel) otherwise(single)
threadCount++;
}
diff --git a/clang/test/OpenMP/metadirective_device_kind_codegen.c b/clang/test/OpenMP/metadirective_device_kind_codegen.c
index f77f50426a16d..0a8c54af2effd 100644
--- a/clang/test/OpenMP/metadirective_device_kind_codegen.c
+++ b/clang/test/OpenMP/metadirective_device_kind_codegen.c
@@ -30,7 +30,7 @@ void foo(void) {
: parallel)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
- : target parallel for) default(parallel for)
+ : target parallel for) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_device_kind_codegen.cpp b/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
index bfbfec8b27e1e..446fd646ef17f 100644
--- a/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
@@ -31,7 +31,7 @@ void foo() {
: parallel)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
- : target parallel for) default(parallel for)
+ : target parallel for) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_empty.cpp b/clang/test/OpenMP/metadirective_empty.cpp
index b93ed722cb6e9..9fcd35e82292d 100644
--- a/clang/test/OpenMP/metadirective_empty.cpp
+++ b/clang/test/OpenMP/metadirective_empty.cpp
@@ -11,12 +11,12 @@ void func() {
// Test where a valid when clause contains empty directive.
// The directive will be ignored and code for a serial for loop will be generated.
#pragma omp metadirective when(implementation = {vendor(llvm)} \
- :) default(parallel for)
+ :) otherwise(parallel for)
for (int i = 0; i < N; i++)
;
#pragma omp metadirective when(implementation = {vendor(llvm)} \
- :nothing) default(parallel for)
+ :nothing) otherwise(parallel for)
for (int i = 0; i < N; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_implementation_codegen.c b/clang/test/OpenMP/metadirective_implementation_codegen.c
index da09b639d6d40..dc0bcbaebd099 100644
--- a/clang/test/OpenMP/metadirective_implementation_codegen.c
+++ b/clang/test/OpenMP/metadirective_implementation_codegen.c
@@ -12,27 +12,27 @@ void foo(void) {
#pragma omp metadirective when(implementation = {vendor(score(0) \
: llvm)}, \
device = {kind(cpu)} \
- : parallel) default(target teams)
+ : parallel) otherwise(target teams)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
: target teams) when(implementation = {vendor(llvm)} \
- : parallel) default()
+ : parallel) otherwise()
bar();
-#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
+#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \
: llvm)}, \
device = {kind(cpu, host)} \
: parallel)
bar();
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_none)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_implementation_codegen.cpp b/clang/test/OpenMP/metadirective_implementation_codegen.cpp
index b9f43d1a1e87c..a20b2e2f14bcd 100644
--- a/clang/test/OpenMP/metadirective_implementation_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_implementation_codegen.cpp
@@ -12,27 +12,27 @@ void foo() {
#pragma omp metadirective when(implementation = {vendor(score(0) \
: llvm)}, \
device = {kind(cpu)} \
- : parallel) default(target teams)
+ : parallel) otherwise(target teams)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
: target teams) when(implementation = {vendor(llvm)} \
- : parallel) default()
+ : parallel) otherwise()
bar();
-#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
+#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \
: llvm)}, \
device = {kind(cpu, host)} \
: parallel)
bar();
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_none)} \
- : parallel) default(parallel for)
+ : parallel) otherwise(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
index b342a094a7870..8a32b36c016d6 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -11,12 +11,16 @@ void foo() {
;
#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
;
-#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+#pragma omp metadirective when(device{arch(nvptx)}: ) otherwise() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
;
-#pragma omp metadirective when(device = {arch(nvptx)} : ) default(xyz) // expected-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
+#pragma omp metadirective when(device = {arch(nvptx)} : ) otherwise(xyz) // expected-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel default() // expected-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
+#pragma omp metadirective when(device = {arch(nvptx)} : parallel otherwise() // expected-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
;
-#pragma omp metadirective when(device = {isa("some-unsupported-feature")} : parallel) default(single) // expected-warning {{isa trait 'some-unsupported-feature' is not known to the current target; verify the spelling or consider restricting the context selector with the 'arch' selector further}}
+#pragma omp metadirective when(device = {isa("some-unsupported-feature")} : parallel) otherwise(single) // expected-warning {{isa trait 'some-unsupported-feature' is not known to the current target; verify the spelling or consider restricting the context selector with the 'arch' selector further}}
+ ;
+#pragma omp metadirective when(device = {arch(nvptx)} : parallel) default() // expected-warning {{'default' clause for 'metadirective' is deprecated; use 'otherwise' instead}}
+ ;
+#pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{unknown clause 'xyz' in metadirective}} expected-error {{use of undeclared identifier 'xyz'}} expected-error {{expected expression}} expected-error {{expected ';' after expression}}
;
}
>From be152cbebf2b5be802f4d98b1639a1ab84194e07 Mon Sep 17 00:00:00 2001
From: Urvi Rav <urvi.rav20 at gmail.com>
Date: Tue, 4 Feb 2025 21:10:21 -0600
Subject: [PATCH 2/6] changes in uknown clause error
---
clang/lib/Parse/ParseOpenMP.cpp | 1 -
clang/test/OpenMP/metadirective_messages.cpp | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 673806ef28b9f..a0f4a2c7a220f 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2747,7 +2747,6 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
if (CKind == OMPC_unknown) {
Diag(Tok, diag::err_omp_unknown_clause)
<< PP.getSpelling(Tok) << "metadirective";
- return Directive;
}
if(CKind == OMPC_default) {
Diag(Tok, diag::warn_omp_default_deprecated);
diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
index 8a32b36c016d6..955bc70e0b966 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -21,6 +21,6 @@ void foo() {
;
#pragma omp metadirective when(device = {arch(nvptx)} : parallel) default() // expected-warning {{'default' clause for 'metadirective' is deprecated; use 'otherwise' instead}}
;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{unknown clause 'xyz' in metadirective}} expected-error {{use of undeclared identifier 'xyz'}} expected-error {{expected expression}} expected-error {{expected ';' after expression}}
+#pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{unknown clause 'xyz' in metadirective}}
;
}
>From 5976ae86e45c0a50a9d409db3c5f30b9cdc5169a Mon Sep 17 00:00:00 2001
From: Urvi Rav <urvi.rav20 at gmail.com>
Date: Thu, 6 Feb 2025 04:37:17 -0600
Subject: [PATCH 3/6] updated clause handling in ParseOpenMP.cpp
---
clang/lib/Parse/ParseOpenMP.cpp | 8 ++-
clang/test/OpenMP/metadirective_ast_print.c | 20 +++---
.../metadirective_device_arch_codegen.cpp | 2 +-
.../metadirective_device_isa_codegen.cpp | 4 +-
...etadirective_device_isa_codegen_amdgcn.cpp | 4 +-
.../metadirective_device_kind_codegen.c | 2 +-
.../metadirective_device_kind_codegen.cpp | 2 +-
clang/test/OpenMP/metadirective_empty.cpp | 4 +-
.../metadirective_implementation_codegen.c | 12 ++--
.../metadirective_implementation_codegen.cpp | 12 ++--
clang/test/OpenMP/metadirective_messages.cpp | 63 +++++++++++++------
11 files changed, 80 insertions(+), 53 deletions(-)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index a0f4a2c7a220f..6ed3d2c779551 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2744,11 +2744,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
// Check if the clause is unrecognized.
- if (CKind == OMPC_unknown) {
+ if (getLangOpts().OpenMP < 52 && (CKind == OMPC_unknown || CKind == OMPC_otherwise)) {
Diag(Tok, diag::err_omp_unknown_clause)
<< PP.getSpelling(Tok) << "metadirective";
}
- if(CKind == OMPC_default) {
+ if (getLangOpts().OpenMP >= 52 && CKind == OMPC_unknown) {
+ Diag(Tok, diag::err_omp_unknown_clause)
+ << PP.getSpelling(Tok) << "metadirective";
+ }
+ if(CKind == OMPC_default && getLangOpts().OpenMP >= 52) {
Diag(Tok, diag::warn_omp_default_deprecated);
}
SourceLocation Loc = ConsumeToken();
diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c
index 28efaac594942..d9ff7e7645216 100644
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ b/clang/test/OpenMP/metadirective_ast_print.c
@@ -15,18 +15,18 @@ void bar(void);
#define N 10
void foo(void) {
#pragma omp metadirective when(device = {kind(cpu)} \
- : parallel) otherwise()
+ : parallel) default()
bar();
#pragma omp metadirective when(implementation = {vendor(score(0) \
: llvm)}, \
device = {kind(cpu)} \
- : parallel) otherwise(target teams)
+ : parallel) default(target teams)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
: target teams) when(implementation = {vendor(llvm)} \
- : parallel) otherwise()
+ : parallel) default()
bar();
-#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \
+#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
: llvm)}, \
device = {kind(cpu, host)} \
: parallel)
@@ -40,15 +40,15 @@ void foo(void) {
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_none)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
@@ -64,17 +64,17 @@ void foo(void) {
#pragma omp metadirective when(device={arch("amdgcn")}: \
teams distribute parallel for)\
- otherwise(parallel for)
+ default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : nothing) otherwise(parallel for)
+ : nothing) default(parallel for)
for (int i = 0; i < 16; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) otherwise(nothing)
+ : parallel) default(nothing)
for (int i = 0; i < 16; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_device_arch_codegen.cpp b/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
index c44337b33d5b3..eecae310d0a77 100644
--- a/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_device_arch_codegen.cpp
@@ -27,7 +27,7 @@ int metadirective1() {
{
#pragma omp metadirective \
when(device={arch("amdgcn")}: teams distribute parallel for) \
- otherwise(parallel for)
+ default(parallel for)
for (int i = 0; i < N; i++) {
#pragma omp atomic write
diff --git a/clang/test/OpenMP/metadirective_device_isa_codegen.cpp b/clang/test/OpenMP/metadirective_device_isa_codegen.cpp
index 1b9829f7a56ce..1d098063101d7 100644
--- a/clang/test/OpenMP/metadirective_device_isa_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_device_isa_codegen.cpp
@@ -8,7 +8,7 @@ void bar();
void x86_64_device_isa_selected() {
#pragma omp metadirective when(device = {isa("sse2")} \
- : parallel) otherwise(single)
+ : parallel) default(single)
bar();
}
// CHECK-LABEL: void @_Z26x86_64_device_isa_selectedv()
@@ -21,7 +21,7 @@ void x86_64_device_isa_selected() {
void x86_64_device_isa_not_selected() {
#pragma omp metadirective when(device = {isa("some-unsupported-feature")} \
- : parallel) otherwise(single)
+ : parallel) default(single)
bar();
}
// CHECK-LABEL: void @_Z30x86_64_device_isa_not_selectedv()
diff --git a/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp b/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
index c2c7b72a8469f..cbb75c4a68376 100644
--- a/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
+++ b/clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
@@ -15,7 +15,7 @@ int amdgcn_device_isa_selected() {
{
#pragma omp metadirective \
when(device = {isa("dpp")} \
- : parallel) otherwise(single)
+ : parallel) default(single)
threadCount++;
}
@@ -38,7 +38,7 @@ int amdgcn_device_isa_not_selected() {
when(device = {isa("sse")} \
: parallel) \
when(device = {isa("another-unsupported-gpu-feature")} \
- : parallel) otherwise(single)
+ : parallel) default(single)
threadCount++;
}
diff --git a/clang/test/OpenMP/metadirective_device_kind_codegen.c b/clang/test/OpenMP/metadirective_device_kind_codegen.c
index 0a8c54af2effd..f77f50426a16d 100644
--- a/clang/test/OpenMP/metadirective_device_kind_codegen.c
+++ b/clang/test/OpenMP/metadirective_device_kind_codegen.c
@@ -30,7 +30,7 @@ void foo(void) {
: parallel)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
- : target parallel for) otherwise(parallel for)
+ : target parallel for) default(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_device_kind_codegen.cpp b/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
index 446fd646ef17f..bfbfec8b27e1e 100644
--- a/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
@@ -31,7 +31,7 @@ void foo() {
: parallel)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
- : target parallel for) otherwise(parallel for)
+ : target parallel for) default(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_empty.cpp b/clang/test/OpenMP/metadirective_empty.cpp
index 9fcd35e82292d..b93ed722cb6e9 100644
--- a/clang/test/OpenMP/metadirective_empty.cpp
+++ b/clang/test/OpenMP/metadirective_empty.cpp
@@ -11,12 +11,12 @@ void func() {
// Test where a valid when clause contains empty directive.
// The directive will be ignored and code for a serial for loop will be generated.
#pragma omp metadirective when(implementation = {vendor(llvm)} \
- :) otherwise(parallel for)
+ :) default(parallel for)
for (int i = 0; i < N; i++)
;
#pragma omp metadirective when(implementation = {vendor(llvm)} \
- :nothing) otherwise(parallel for)
+ :nothing) default(parallel for)
for (int i = 0; i < N; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_implementation_codegen.c b/clang/test/OpenMP/metadirective_implementation_codegen.c
index dc0bcbaebd099..da09b639d6d40 100644
--- a/clang/test/OpenMP/metadirective_implementation_codegen.c
+++ b/clang/test/OpenMP/metadirective_implementation_codegen.c
@@ -12,27 +12,27 @@ void foo(void) {
#pragma omp metadirective when(implementation = {vendor(score(0) \
: llvm)}, \
device = {kind(cpu)} \
- : parallel) otherwise(target teams)
+ : parallel) default(target teams)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
: target teams) when(implementation = {vendor(llvm)} \
- : parallel) otherwise()
+ : parallel) default()
bar();
-#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \
+#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
: llvm)}, \
device = {kind(cpu, host)} \
: parallel)
bar();
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_none)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_implementation_codegen.cpp b/clang/test/OpenMP/metadirective_implementation_codegen.cpp
index a20b2e2f14bcd..b9f43d1a1e87c 100644
--- a/clang/test/OpenMP/metadirective_implementation_codegen.cpp
+++ b/clang/test/OpenMP/metadirective_implementation_codegen.cpp
@@ -12,27 +12,27 @@ void foo() {
#pragma omp metadirective when(implementation = {vendor(score(0) \
: llvm)}, \
device = {kind(cpu)} \
- : parallel) otherwise(target teams)
+ : parallel) default(target teams)
bar();
#pragma omp metadirective when(device = {kind(gpu)} \
: target teams) when(implementation = {vendor(llvm)} \
- : parallel) otherwise()
+ : parallel) default()
bar();
-#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \
+#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
: llvm)}, \
device = {kind(cpu, host)} \
: parallel)
bar();
#pragma omp metadirective when(implementation = {extension(match_all)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_any)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
#pragma omp metadirective when(implementation = {extension(match_none)} \
- : parallel) otherwise(parallel for)
+ : parallel) default(parallel for)
for (int i = 0; i < 100; i++)
;
}
diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
index 955bc70e0b966..7645a316c3d3c 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -2,25 +2,48 @@
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s
+// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized
+
void foo() {
-#pragma omp metadirective // expected-error {{expected expression}}
- ;
-#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
- ;
-#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
- ;
-#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
- ;
-#pragma omp metadirective when(device{arch(nvptx)}: ) otherwise() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
- ;
-#pragma omp metadirective when(device = {arch(nvptx)} : ) otherwise(xyz) // expected-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
- ;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel otherwise() // expected-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
- ;
-#pragma omp metadirective when(device = {isa("some-unsupported-feature")} : parallel) otherwise(single) // expected-warning {{isa trait 'some-unsupported-feature' is not known to the current target; verify the spelling or consider restricting the context selector with the 'arch' selector further}}
- ;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel) default() // expected-warning {{'default' clause for 'metadirective' is deprecated; use 'otherwise' instead}}
- ;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{unknown clause 'xyz' in metadirective}}
- ;
+#if _OPENMP >= 202111
+ #pragma omp metadirective // omp52-error {{expected expression}}
+ ;
+ #pragma omp metadirective when() // omp52-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+ ;
+ #pragma omp metadirective when(device{}) // omp52-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
+ ;
+ #pragma omp metadirective when(device{arch(nvptx)}) // omp52-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+ ;
+ #pragma omp metadirective when(device{arch(nvptx)}: ) otherwise() // omp52-warning {{expected '=' after the context set name "device"; '=' assumed}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : ) otherwise(xyz) // omp52-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : parallel otherwise() // omp52-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
+ ;
+ #pragma omp metadirective when(device = {isa("some-unsupported-feature")} : parallel) otherwise(single) // omp52-warning {{isa trait 'some-unsupported-feature' is not known to the current target; verify the spelling or consider restricting the context selector with the 'arch' selector further}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : parallel) default() // omp52-warning {{'default' clause for 'metadirective' is deprecated; use 'otherwise' instead}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //omp52-error {{unknown clause 'xyz' in metadirective}}
+ ;
+#else
+ #pragma omp metadirective // expected-error {{expected expression}}
+ ;
+ #pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+ ;
+ #pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
+ ;
+ #pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+ ;
+ #pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : ) default(xyz) // expected-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : parallel default() // expected-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
+ ;
+ #pragma omp metadirective when(device = {isa("some-unsupported-feature")} : parallel) default(single) // expected-warning {{isa trait 'some-unsupported-feature' is not known to the current target; verify the spelling or consider restricting the context selector with the 'arch' selector further}}
+ ;
+ #pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{unknown clause 'xyz' in metadirective}}
+ ;
+#endif
}
>From ee902c936a2d85e5cbde32196f9322305a0a146c Mon Sep 17 00:00:00 2001
From: Urvi Rav <94829943+ravurvi20 at users.noreply.github.com>
Date: Fri, 7 Feb 2025 11:06:27 +0530
Subject: [PATCH 4/6] Update metadirective_messages.cpp
---
clang/test/OpenMP/metadirective_messages.cpp | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
index 144c7c5621813..7645a316c3d3c 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -5,7 +5,6 @@
// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized
void foo() {
-
#if _OPENMP >= 202111
#pragma omp metadirective // omp52-error {{expected expression}}
;
@@ -47,22 +46,4 @@ void foo() {
#pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{unknown clause 'xyz' in metadirective}}
;
#endif
-
-#pragma omp metadirective // expected-error {{expected expression}}
- ;
-#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
- ;
-#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
- ;
-#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
- ;
-#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
- ;
-#pragma omp metadirective when(device = {arch(nvptx)} : ) default(xyz) // expected-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
- ;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel default() // expected-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
- ;
-#pragma omp metadirective when(device = {isa("some-unsupported-feature")} : parallel) default(single) // expected-warning {{isa trait 'some-unsupported-feature' is not known to the current target; verify the spelling or consider restricting the context selector with the 'arch' selector further}}
- ;
-
}
>From 1eb84f36a3e4c413ec98d554f8b58bae8c48e857 Mon Sep 17 00:00:00 2001
From: Urvi Rav <94829943+ravurvi20 at users.noreply.github.com>
Date: Fri, 7 Feb 2025 11:31:50 +0530
Subject: [PATCH 5/6] Update metadirective_messages.cpp
---
clang/test/OpenMP/metadirective_messages.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
index 7645a316c3d3c..b3507be3ef27d 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -29,7 +29,7 @@ void foo() {
#else
#pragma omp metadirective // expected-error {{expected expression}}
;
- #pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+ #pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
;
#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
;
>From ac2d297fc378fc21a692797b2f471b3b027183e4 Mon Sep 17 00:00:00 2001
From: Urvi Rav <94829943+ravurvi20 at users.noreply.github.com>
Date: Fri, 7 Feb 2025 12:03:38 +0530
Subject: [PATCH 6/6] Update metadirective_messages.cpp
---
clang/test/OpenMP/metadirective_messages.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
index b3507be3ef27d..8e90bcc014b60 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -8,7 +8,7 @@ void foo() {
#if _OPENMP >= 202111
#pragma omp metadirective // omp52-error {{expected expression}}
;
- #pragma omp metadirective when() // omp52-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+ #pragma omp metadirective when() // omp52-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
;
#pragma omp metadirective when(device{}) // omp52-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
;
More information about the cfe-commits
mailing list