[flang-commits] [flang] [flang] A module that USEs itself directly in its specification part … (PR #228489)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Oct 19 08:57:44 PDT 2026


================
@@ -4916,7 +4916,8 @@ Scope *ModuleVisitor::FindModule(const parser::Name &name,
   Scope *scope{
       reader.Read(name.source, isIntrinsic, ancestor, /*silent=*/false)};
   if (scope) {
-    if (DoesScopeContain(scope, currScope())) { // 14.2.2(1)
+    if (DoesScopeContain(scope, currScope()) ||
+        scope->Contains(currScope())) { // 14.2.2(1)
----------------
eugeneepshteyn wrote:

The first operand is now redundant. `DoesScopeContain(scope, x)` walks up from `x.parent()`, while `Scope::Contains` starts at `x` itself, so whenever the first is true the second is too. The comment should also cite the standard as flang/docs/C++style.md asks:

```suggestion
    if (scope->Contains(currScope())) { // F2023 14.2.2 p1
```

https://github.com/llvm/llvm-project/pull/228489


More information about the flang-commits mailing list