[flang-commits] [flang] 0e28fe6 - [flang] NORM2(DIM=) argument can't be dynamically optional
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Apr 3 09:04:40 PDT 2023
Author: Peter Klausler
Date: 2023-04-03T09:00:22-07:00
New Revision: 0e28fe62c75658561569603136dff3c271d95a6e
URL: https://github.com/llvm/llvm-project/commit/0e28fe62c75658561569603136dff3c271d95a6e
DIFF: https://github.com/llvm/llvm-project/commit/0e28fe62c75658561569603136dff3c271d95a6e.diff
LOG: [flang] NORM2(DIM=) argument can't be dynamically optional
The intrinsic function table entry for NORM2 treats its DIM=
argument as if it can be dynamically optional; this is wrong,
and it should be treated in the same way as DIM= is for other
transformational intrinsic functions like SUM.
Differential Revision: https://reviews.llvm.org/D147390
Added:
Modified:
flang/lib/Evaluate/intrinsics.cpp
flang/test/Semantics/dim01.f90
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index e82b62e6f7c52..41e1e5c01cdcb 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -685,8 +685,10 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
common::Intent::In, {ArgFlag::canBeNull}}},
SameCharNoLen, Rank::scalar, IntrinsicClass::inquiryFunction},
{"nint", {{"a", AnyReal}, DefaultingKIND}, KINDInt},
- {"norm2", {{"x", SameReal, Rank::array}, OptionalDIM}, SameReal,
+ {"norm2", {{"x", SameReal, Rank::array}, RequiredDIM}, SameReal,
Rank::dimReduced, IntrinsicClass::transformationalFunction},
+ {"norm2", {{"x", SameReal, Rank::array}, MissingDIM}, SameReal,
+ Rank::scalar, IntrinsicClass::transformationalFunction},
{"not", {{"i", SameInt}}, SameInt},
// NULL() is a special case handled in Probe() below
{"num_images", {}, DefaultInt, Rank::scalar,
diff --git a/flang/test/Semantics/dim01.f90 b/flang/test/Semantics/dim01.f90
index 48c0291b58f9e..2d56eb5853248 100644
--- a/flang/test/Semantics/dim01.f90
+++ b/flang/test/Semantics/dim01.f90
@@ -18,6 +18,8 @@ function f1(a,d)
integer, optional, intent(in) :: d
!PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time
f1 = sum(a,dim=d)
+ !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time
+ f1 = norm2(a,dim=d)
end function
function f2(a,d)
real, intent(in) :: a(:)
@@ -49,6 +51,8 @@ function f11(a,d)
real, allocatable :: f11(:)
!WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
f11 = sum(a,dim=d)
+ !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
+ f11 = norm2(a,dim=d)
end function
function f12(a,d)
real, intent(in) :: a(:,:)
@@ -65,4 +69,3 @@ function f13(a,d)
f13 = sum(a,dim=d)
end function
end module
-
More information about the flang-commits
mailing list