[PATCH] D120973: [flang] Allow to use already existing names for contruct-name

Mike K via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 8 20:34:17 PST 2022


FruitClover added inline comments.


================
Comment at: flang/lib/Semantics/resolve-names.cpp:615
+  bool isSameSymbolNameAllowed(Symbol &symbol, MiscDetails details) {
+    if (details.kind() == MiscDetails::Kind::ConstructName &&
+        symbol.has<ObjectEntityDetails>()) {
----------------
klausler wrote:
> Two things here: first, this doesn't need to be an if statement, it can be just a simple return statement.
> 
> Second, why allow this only for object entities?  Wouldn't any symbol other than another construct name be allowable?
> Second, why allow this only for object entities? Wouldn't any symbol other than another construct name be allowable?

You are right and actually there is uncovered case when variable named as construct-name used inside construct scope: (from Fortran 2018, 19.3, also asked gfortran folks here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104812 to be sure)
```
subroutine s1
  logical :: x
  x: if (x) then  ! should be an error
  end if x
end
``` 
Is `ScopeHandler::PushScope` the right place for such fix or it should be done in `expression.cpp`? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120973/new/

https://reviews.llvm.org/D120973



More information about the llvm-commits mailing list