[PATCH] D99085: [flang] Specific procedures named the same as the generic and a derived type

Pete Steinfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 22 09:05:27 PDT 2021


PeteSteinfeld created this revision.
PeteSteinfeld added reviewers: klausler, tskeith.
PeteSteinfeld requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If you specify a specific procedure of a generic interface that has the same
name as both the generic interface and a preceding derived type, the compiler
would fail an internal call to CHECK().  I fixed this by testing for this
situation when processing specific procedures.  I also added a test that will
cause the call to CHECK() to fail without this new code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99085

Files:
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/resolve18.f90


Index: flang/test/Semantics/resolve18.f90
===================================================================
--- flang/test/Semantics/resolve18.f90
+++ flang/test/Semantics/resolve18.f90
@@ -63,6 +63,15 @@
   function foo(x)
   end
 end
+module m4c
+  type :: foo
+  end type
+  interface foo
+    !ERROR: 'foo' is already declared in this scoping unit
+    real function foo()
+    end function foo
+  end interface foo
+end
 
 ! Use associating a name that is a generic and a derived type
 module m5a
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -3248,7 +3248,12 @@
       if (!specific) {
         specific =
             &currScope().MakeSymbol(name.source, Attrs{}, SubprogramDetails{});
-        details->set_specific(Resolve(name, *specific));
+        if (details->derivedType()) {
+          // A specific procedure with the same name as a derived type
+          SayAlreadyDeclared(name, *details->derivedType());
+        } else {
+          details->set_specific(Resolve(name, *specific));
+        }
       } else if (isGeneric()) {
         SayAlreadyDeclared(name, *specific);
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99085.332311.patch
Type: text/x-patch
Size: 1257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210322/2ac840df/attachment.bin>


More information about the llvm-commits mailing list