[flang] unparse interfaces as PROCEDURE(TYPE(REAL)) to avoid ambiguity
authorpeter klausler <pklausler@nvidia.com>
Wed, 27 Feb 2019 20:30:57 +0000 (12:30 -0800)
committerpeter klausler <pklausler@nvidia.com>
Wed, 27 Feb 2019 20:30:57 +0000 (12:30 -0800)
Original-commit: flang-compiler/f18@efef1f1ad13acc65b37e73efa25b9402ab6c0bb5
Reviewed-on: https://github.com/flang-compiler/f18/pull/304

flang/lib/parser/unparse.cc
flang/test/semantics/procinterface01.f90
flang/test/semantics/symbol08.f90

index 891f5c3..d9785e4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -1622,6 +1622,25 @@ public:
     Put(')'), Walk(", ", std::get<std::list<ProcAttrSpec>>(x.t), ", ");
     Put(" :: "), Walk(std::get<std::list<ProcDecl>>(x.t), ", ");
   }
+  void Unparse(const ProcInterface &x) {  // R1513
+    std::visit(
+        common::visitors{
+            [&](const DeclarationTypeSpec &d) {
+              std::visit(
+                  common::visitors{
+                      [&](const IntrinsicTypeSpec &t) {
+                        // Emit TYPE(REAL) to ensure no conflict with a symbol
+                        // REAL
+                        Word("TYPE("), Walk(t), Word(")");
+                      },
+                      [&](const auto &t) { Walk(t); },
+                  },
+                  d.u);
+            },
+            [&](const Name &n) { Walk(n); },
+        },
+        x.u);
+  }
   void Unparse(const ProcDecl &x) {  // R1515
     Walk(std::get<Name>(x.t));
     Walk(" => ", std::get<std::optional<ProcPointerInit>>(x.t));
index adee9c6..2dca54b 100644 (file)
@@ -63,10 +63,10 @@ module module1
   procedure(logical), pointer, nopass :: p3 => nested2
   !DEF: /module1/derived1/p4 NOPASS, POINTER ProcEntity LOGICAL(4)
   !DEF: /module1/nested3 PUBLIC Subprogram
-  procedure(logical(kind=4)), pointer, nopass :: p4 => nested3
+  procedure(type(logical(kind=4))), pointer, nopass :: p4 => nested3
   !DEF: /module1/derived1/p5 NOPASS, POINTER ProcEntity COMPLEX(4)
   !DEF: /module1/nested4 PUBLIC Subprogram
-  procedure(complex), pointer, nopass :: p5 => nested4
+  procedure(type(complex)), pointer, nopass :: p5 => nested4
   !DEF: /module1/derived1/p6 NOPASS, POINTER ProcEntity
   !REF: /module1/nested1
   ! NOTE: sin is not dumped as a DEF here because specific
index 7e226be..2f28879 100644 (file)
@@ -21,7 +21,7 @@ program main
  !DEF: /main/y EXTERNAL, POINTER ProcEntity REAL(4)
  pointer :: y
  !REF: /main/y
- procedure (real) :: y
+ procedure (type(real)) :: y
  !DEF: /main/z (implicit) ObjectEntity REAL(4)
  !REF: /main/y
  z = y()