[flang] Fix call to CHECK() on erroneous subroutine declaration
authorPeter Steinfeld <psteinfeld@nvidia.com>
Tue, 20 Oct 2020 22:05:35 +0000 (15:05 -0700)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Wed, 21 Oct 2020 01:09:15 +0000 (18:09 -0700)
When processing declarations in resolve-names.cpp, we were returning a
symbol that had SubprogramName details to PushSubprogramScope(), which
expects a symbol with Subprogram details.

I adjusted the code and added a test.

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

flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve19.f90

index 0bdf871..40ece09 100644 (file)
@@ -3048,7 +3048,8 @@ Symbol *SubprogramVisitor::GetSpecificFromGeneric(const parser::Name &name) {
         details->set_specific(Resolve(name, *specific));
       } else if (isGeneric()) {
         SayAlreadyDeclared(name, *specific);
-      } else if (!specific->has<SubprogramDetails>()) {
+      }
+      if (!specific->has<SubprogramDetails>()) {
         specific->set_details(SubprogramDetails{});
       }
       return specific;
index dd91e41..b8fe8e8 100644 (file)
@@ -22,3 +22,14 @@ module m2
     end subroutine
   end interface
 end module
+
+module m3
+  interface s
+    subroutine s
+    end
+  end interface
+contains
+  !ERROR: 's' is already declared in this scoping unit
+  subroutine s
+  end subroutine
+end