[flang] Don't add inherited procedures to generic binding
authorTim Keith <tkeith@nvidia.com>
Thu, 21 Mar 2019 00:00:26 +0000 (17:00 -0700)
committerTim Keith <tkeith@nvidia.com>
Fri, 29 Mar 2019 16:07:27 +0000 (09:07 -0700)
In this example:
```
  type t1
  contains
    procedure, nopass :: s1
    generic :: foo => s1
  end type
  type, extends(t1) :: t2
  contains
    procedure, nopass :: s2
    generic :: foo => s2
  end type
```

The GenericBindingDetails for foo in t2 include both s1 and s2 as
specific procs. There is no way to distinguish between the binding in
the current type and the binding that was inherited. In particular,
the .mod file will have a binding for s1 in t2, so it won't match the
original source (for exampke, see the old version of modfile14.f90).

Original-commit: flang-compiler/f18@4e2c6be5cbdc5d31c41f0e44b85985b4fb69210d
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false

flang/lib/semantics/resolve-names.cc
flang/test/semantics/modfile14.f90

index 514a6a3..8073bbd 100644 (file)
@@ -3278,7 +3278,6 @@ bool DeclarationVisitor::Pre(const parser::TypeBoundGenericStmt &x) {
   const SourceName &symbolName{info.symbolName()};
   bool isPrivate{accessSpec ? accessSpec->v == parser::AccessSpec::Kind::Private
                             : derivedTypeInfo_.privateBindings};
-  const SymbolList *inheritedProcs{nullptr};  // specific procs from parent type
   auto *genericSymbol{FindInScope(currScope(), symbolName)};
   if (genericSymbol) {
     if (!genericSymbol->has<GenericBindingDetails>()) {
@@ -3288,8 +3287,6 @@ bool DeclarationVisitor::Pre(const parser::TypeBoundGenericStmt &x) {
                  FindInTypeOrParents(currScope(), symbolName)}) {
     // look in parent types:
     if (inheritedSymbol->has<GenericBindingDetails>()) {
-      inheritedProcs =
-          &inheritedSymbol->get<GenericBindingDetails>().specificProcs();
       CheckAccessibility(symbolName, isPrivate, *inheritedSymbol);
     }
   }
@@ -3305,9 +3302,6 @@ bool DeclarationVisitor::Pre(const parser::TypeBoundGenericStmt &x) {
     }
   }
   auto &details{genericSymbol->get<GenericBindingDetails>()};
-  if (inheritedProcs) {
-    details.add_specificProcs(*inheritedProcs);
-  }
   details.add_specificProcs(specificProcs);
   info.Resolve(genericSymbol);
   return false;
index d504685..99bbb0e 100644 (file)
@@ -58,7 +58,6 @@ end
 !  type,extends(t1)::t2
 !  contains
 !    procedure,nopass::s4
-!    generic::foo=>s2
 !    generic::foo=>s3
 !    generic::foo=>s4
 !  end type