[llvm-branch-commits] [flang] [flang][OpenMP] Refactor/update semantic checks for ALLOCATE directive (PR #164420)
Krzysztof Parzyszek via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 22 05:48:27 PDT 2025
================
@@ -1680,40 +1710,92 @@ void OmpStructureChecker::Leave(const parser::OpenMPRequiresConstruct &) {
dirContext_.pop_back();
}
-void OmpStructureChecker::Enter(const parser::OpenMPDeclarativeAllocate &x) {
- isPredefinedAllocator = true;
- const auto &dir{std::get<parser::Verbatim>(x.t)};
- const auto &objectList{std::get<parser::OmpObjectList>(x.t)};
- PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_allocate);
- SymbolSourceMap currSymbols;
- GetSymbolsInObjectList(objectList, currSymbols);
- for (auto &[symbol, source] : currSymbols) {
- if (IsPointer(*symbol)) {
+void OmpStructureChecker::CheckAllocateDirective(parser::CharBlock source,
+ const parser::OmpObjectList &objects,
+ const parser::OmpClauseList &clauses) {
+ const Scope &thisScope{context_.FindScope(source)};
+ SymbolSourceMap symbols;
+ GetSymbolsInObjectList(objects, symbols);
+
+ auto hasPredefinedAllocator{[&](const parser::OmpClause *c) {
+ if (!c) {
+ return std::make_optional(false);
+ }
+ auto *allocator{std::get_if<parser::OmpClause::Allocator>(&c->u)};
----------------
kparzysz wrote:
Got rid of the optional. Now the code is checking whether the value could possibly be a predefined allocator. If not, we emit an error, not a warning. We won't emit anything if it's an expression that could potentially be a predefined allocator.
https://github.com/llvm/llvm-project/pull/164420
More information about the llvm-branch-commits
mailing list