[clang] 85ea1aa - [OpenACC] Fix device_type clause appertainment
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 08:43:53 PDT 2024
Author: erichkeane
Date: 2024-05-31T08:43:48-07:00
New Revision: 85ea1aaf15b3721aaea35280ffdedad36128bf6b
URL: https://github.com/llvm/llvm-project/commit/85ea1aaf15b3721aaea35280ffdedad36128bf6b
DIFF: https://github.com/llvm/llvm-project/commit/85ea1aaf15b3721aaea35280ffdedad36128bf6b.diff
LOG: [OpenACC] Fix device_type clause appertainment
Seemingly I forgot to implement the appertainment checks when doing the
original device_type implementation, so we fell through to the 'not
implemented' section of the diagnostics.
This patch corrects the appertainment, so that we disallow it correctly.
Added:
Modified:
clang/lib/Sema/SemaOpenACC.cpp
clang/test/SemaOpenACC/compute-construct-device_type-clause.c
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 15239f4f35c39..6ae3c64bbf82c 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -246,6 +246,27 @@ bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind,
return false;
}
+ case OpenACCClauseKind::DeviceType:
+ case OpenACCClauseKind::DType:
+ switch (DirectiveKind) {
+ case OpenACCDirectiveKind::Parallel:
+ case OpenACCDirectiveKind::Serial:
+ case OpenACCDirectiveKind::Kernels:
+ case OpenACCDirectiveKind::Data:
+ case OpenACCDirectiveKind::Init:
+ case OpenACCDirectiveKind::Shutdown:
+ case OpenACCDirectiveKind::Set:
+ case OpenACCDirectiveKind::Update:
+ case OpenACCDirectiveKind::Loop:
+ case OpenACCDirectiveKind::Routine:
+ case OpenACCDirectiveKind::ParallelLoop:
+ case OpenACCDirectiveKind::SerialLoop:
+ case OpenACCDirectiveKind::KernelsLoop:
+ return true;
+ default:
+ return false;
+ }
+
default:
// Do nothing so we can go to the 'unimplemented' diagnostic instead.
return true;
diff --git a/clang/test/SemaOpenACC/compute-construct-device_type-clause.c b/clang/test/SemaOpenACC/compute-construct-device_type-clause.c
index bf2a00a0f7360..376a741a2a6b9 100644
--- a/clang/test/SemaOpenACC/compute-construct-device_type-clause.c
+++ b/clang/test/SemaOpenACC/compute-construct-device_type-clause.c
@@ -34,6 +34,13 @@ void uses() {
#pragma acc kernels dtype(MACRO)
while(1);
+ // expected-error at +2{{OpenACC 'device_type' clause is not valid on 'enter data' directive}}
+ // expected-warning at +1{{OpenACC construct 'enter data' not yet implemented}}
+#pragma acc enter data device_type(I)
+ // expected-error at +2{{OpenACC 'dtype' clause is not valid on 'enter data' directive}}
+ // expected-warning at +1{{OpenACC construct 'enter data' not yet implemented}}
+#pragma acc enter data dtype(I)
+
// Only 'async', 'wait', num_gangs', 'num_workers', 'vector_length' allowed after 'device_type'.
More information about the cfe-commits
mailing list