[all-commits] [llvm/llvm-project] b7f831: [flang] Avoid crash from forward referenced derive...

Peter Klausler via All-commits all-commits at lists.llvm.org
Wed Jul 13 16:58:45 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b7f83142701b46d58498eb95f6b7b04758495127
      https://github.com/llvm/llvm-project/commit/b7f83142701b46d58498eb95f6b7b04758495127
  Author: Peter Klausler <pklausler at nvidia.com>
  Date:   2022-07-13 (Wed, 13 Jul 2022)

  Changed paths:
    M flang/lib/Semantics/resolve-names.cpp
    A flang/test/Semantics/symbol21.f90

  Log Message:
  -----------
  [flang] Avoid crash from forward referenced derived type

Fortran permits forward references to derived types in contexts that don't
require knowledge of the derived type definition for semantic analysis,
such as in the declaration of a pointer or allocatable variable or component.
But when the forward-referenced derived type is used later for a component
reference, it is possible for the DerivedTypeSpec in he base variable or component
declaration to still have a null scope pointer even if the type has been defined,
since DerivedTypeSpec and TypeSpec objects are created in scopes of use
rather than in scopes of definition.  The fix is to call
DerivedTypeSpec::Instantiate() in the name resolution of each component
name so that the scope gets filled in if it is still null.

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




More information about the All-commits mailing list