[clang] [OpenACC] Fix scope setup for OpenACC directives without scope. (PR #203687)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 13 01:18:01 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Erich Keane (erichkeane)
<details>
<summary>Changes</summary>
When implementing these, I intended to have the 'empty' parse scopes for most of the directives introduced for simplicity. However some assertions show that this is not a valid use of this, as it doesn't tolerate 'empty' parse scopes. This patch stops introducing one.
Fixes: #<!-- -->203679
---
Full diff: https://github.com/llvm/llvm-project/pull/203687.diff
2 Files Affected:
- (modified) clang/lib/Parse/ParseOpenACC.cpp (+3-1)
- (renamed) clang/test/ParserOpenACC/directive-scope-setup.cpp (+2)
``````````diff
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index a95c5730a001c..ba6f25de0ed6b 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -1682,7 +1682,9 @@ StmtResult Parser::ParseOpenACCDirectiveStmt() {
getActions().OpenACC(), DirInfo.DirKind, DirInfo.DirLoc, {},
DirInfo.Clauses);
ParsingOpenACCDirectiveRAII DirScope(*this, /*Value=*/false);
- ParseScope ACCScope(this, getOpenACCScopeFlags(DirInfo.DirKind));
+
+ unsigned scopeFlags = getOpenACCScopeFlags(DirInfo.DirKind);
+ ParseScope ACCScope(this, scopeFlags, /*EnteredScope=*/scopeFlags != 0);
AssocStmt = getActions().OpenACC().ActOnAssociatedStmt(
DirInfo.StartLoc, DirInfo.DirKind, DirInfo.AtomicKind, DirInfo.Clauses,
diff --git a/clang/test/ParserOpenACC/gh197858.cpp b/clang/test/ParserOpenACC/directive-scope-setup.cpp
similarity index 76%
rename from clang/test/ParserOpenACC/gh197858.cpp
rename to clang/test/ParserOpenACC/directive-scope-setup.cpp
index 20046d79c3f16..8fdc3cc9ac4fa 100644
--- a/clang/test/ParserOpenACC/gh197858.cpp
+++ b/clang/test/ParserOpenACC/directive-scope-setup.cpp
@@ -7,4 +7,6 @@ void func() {
using j; // expected-error{{using declaration requires a qualified name}}
#pragma acc parallel loop
using k; // expected-error{{using declaration requires a qualified name}}
+#pragma acc data default(none)
+ using l; // expected-error{{using declaration requires a qualified name}}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/203687
More information about the cfe-commits
mailing list