[flang-commits] [flang] [Flang][Semantics] Allow declare target to be used on functions external to the declare targets scope (PR #122546)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Fri Jan 17 05:40:12 PST 2025
================
@@ -8298,6 +8345,44 @@ const parser::Name *DeclarationVisitor::FindComponent(
return nullptr;
}
+bool DeclarationVisitor::FindAndMarkDeclareTargetSymbol(
+ const parser::Name &name) {
+ if (!specPartState_.declareTargetNames.empty()) {
+ if (specPartState_.declareTargetNames.find(name.source) !=
+ specPartState_.declareTargetNames.end()) {
+ if (!currScope().IsTopLevel()) {
+ // Search preceding scopes until we find a matching symbol or run out
+ // of scopes to search, we skip the current scope as it's already been
+ // designated as implicit here.
+ Symbol *symbol = nullptr;
+ for (auto *scope = &currScope().parent();; scope = &scope->parent()) {
+ symbol = scope->FindSymbol(name.source);
+ if (symbol) {
----------------
kparzysz wrote:
This could be
```
if (Symbol *symbol{scope->FindSymbol(name.source)}) { ...
```
and remove the declaration of "symbol" at like 8357.
https://github.com/llvm/llvm-project/pull/122546
More information about the flang-commits
mailing list