[PATCH] D90074: [flang] An erroneous type bound procedure was causing a call to CHECK()

Pete Steinfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 13:12:20 PDT 2020


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

I added a test to verify that the associated symbol did not have errors before
doing the anaylsis of a call to a component ref along with a test that
triggers the original problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90074

Files:
  flang/lib/Semantics/expression.cpp
  flang/test/Semantics/bindings01.f90


Index: flang/test/Semantics/bindings01.f90
===================================================================
--- flang/test/Semantics/bindings01.f90
+++ flang/test/Semantics/bindings01.f90
@@ -114,3 +114,28 @@
   end subroutine s7
 end module
 
+module m1
+  implicit none
+  interface g
+    module procedure mp
+  end interface g
+
+  type t
+  contains
+    !ERROR: The binding of 'tbp' ('g') must be either an accessible module procedure or an external procedure with an explicit interface
+    procedure,pass(x) :: tbp => g
+  end type t
+
+contains
+  subroutine mp(x)
+    class(t),intent(in) :: x
+  end subroutine
+end module m1
+
+program test
+  use m1
+  type,extends(t) :: t2
+  end type
+  type(t2) a
+  call a%tbp
+end program
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -1700,6 +1700,9 @@
   const parser::StructureComponent &sc{pcr.v.thing};
   if (MaybeExpr base{Analyze(sc.base)}) {
     if (const Symbol * sym{sc.component.symbol}) {
+      if (context_.HasError(sym)) {
+        return std::nullopt;
+      }
       if (auto *dtExpr{UnwrapExpr<Expr<SomeDerived>>(*base)}) {
         if (sym->has<semantics::GenericDetails>()) {
           AdjustActuals adjustment{


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90074.300393.patch
Type: text/x-patch
Size: 1335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201023/badadca0/attachment.bin>


More information about the llvm-commits mailing list