[PATCH] D103832: [flang] Check for calling a type parameter as a function
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 7 11:27:20 PDT 2021
PeteSteinfeld created this revision.
PeteSteinfeld requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
It's possible to refer to type type parameter of a derived type as a function.
We were not detecting this situation and emitting an error message. I added
the necessary check along with a test.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103832
Files:
flang/lib/Semantics/expression.cpp
flang/test/Semantics/resolve59.f90
Index: flang/test/Semantics/resolve59.f90
===================================================================
--- flang/test/Semantics/resolve59.f90
+++ flang/test/Semantics/resolve59.f90
@@ -136,3 +136,16 @@
!ERROR: Reference to rank-2 object 'x' has 3 subscripts
y = x(1, 2, 3)
end
+
+subroutine with_type_param
+ type derived(typeParam)
+ integer,kind :: typeParam
+ integer :: field(typeParam)
+ end type
+ type(derived(3)) x
+ x = derived(3)([11,22,33])
+ !ERROR: 'typeparam' is not a function
+ print *,x%typeParam()
+ !ERROR: Reference to array 'field' with empty subscript list
+ print *,x%field()
+end
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -2739,7 +2739,8 @@
proc.u)}) {
Symbol &symbol{origSymbol->GetUltimate()};
if (symbol.has<semantics::ObjectEntityDetails>() ||
- symbol.has<semantics::AssocEntityDetails>()) {
+ symbol.has<semantics::AssocEntityDetails>() ||
+ symbol.has<semantics::TypeParamDetails>()) {
// Note that expression in AssocEntityDetails cannot be a procedure
// pointer as per C1105 so this cannot be a function reference.
if constexpr (common::HasMember<common::Indirection<parser::Designator>,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103832.350368.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210607/484234f1/attachment.bin>
More information about the llvm-commits
mailing list