From: peter klausler Date: Wed, 27 Feb 2019 20:30:57 +0000 (-0800) Subject: [flang] unparse interfaces as PROCEDURE(TYPE(REAL)) to avoid ambiguity X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=204a50d2836d590f7856a1244f904eba0e4d1938;p=platform%2Fupstream%2Fllvm.git [flang] unparse interfaces as PROCEDURE(TYPE(REAL)) to avoid ambiguity Original-commit: flang-compiler/f18@efef1f1ad13acc65b37e73efa25b9402ab6c0bb5 Reviewed-on: https://github.com/flang-compiler/f18/pull/304 --- diff --git a/flang/lib/parser/unparse.cc b/flang/lib/parser/unparse.cc index 891f5c3..d9785e4 100644 --- a/flang/lib/parser/unparse.cc +++ b/flang/lib/parser/unparse.cc @@ -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>(x.t), ", "); Put(" :: "), Walk(std::get>(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(x.t)); Walk(" => ", std::get>(x.t)); diff --git a/flang/test/semantics/procinterface01.f90 b/flang/test/semantics/procinterface01.f90 index adee9c6..2dca54b 100644 --- a/flang/test/semantics/procinterface01.f90 +++ b/flang/test/semantics/procinterface01.f90 @@ -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 diff --git a/flang/test/semantics/symbol08.f90 b/flang/test/semantics/symbol08.f90 index 7e226be..2f28879 100644 --- a/flang/test/semantics/symbol08.f90 +++ b/flang/test/semantics/symbol08.f90 @@ -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()