[flang-commits] [flang] 5727df2 - [flang] Specific procedures named the same as the generic and a derived type

Peter Steinfeld via flang-commits flang-commits at lists.llvm.org
Mon Mar 22 10:53:07 PDT 2021


Author: Peter Steinfeld
Date: 2021-03-22T10:52:50-07:00
New Revision: 5727df2714985f53b2794e9672865554612cc155

URL: https://github.com/llvm/llvm-project/commit/5727df2714985f53b2794e9672865554612cc155
DIFF: https://github.com/llvm/llvm-project/commit/5727df2714985f53b2794e9672865554612cc155.diff

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

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.

Differential Revision: https://reviews.llvm.org/D99085

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 398f45c5c4ae..f69e7702559f 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -3248,7 +3248,12 @@ Symbol *SubprogramVisitor::GetSpecificFromGeneric(const parser::Name &name) {
       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);
       }

diff  --git a/flang/test/Semantics/resolve18.f90 b/flang/test/Semantics/resolve18.f90
index 94b217e248f0..dd9214533b26 100644
--- a/flang/test/Semantics/resolve18.f90
+++ b/flang/test/Semantics/resolve18.f90
@@ -63,6 +63,15 @@ module m4b
   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


        


More information about the flang-commits mailing list