Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions flang/lib/Evaluate/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1336,19 +1336,19 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
{{"log", {{"x", DefaultReal}}, DefaultReal}},
{{"log10", {{"x", DefaultReal}}, DefaultReal}},
{{"max0",
{{"a1", DefaultInt}, {"a2", DefaultInt},
{"a3", DefaultInt, Rank::elemental, Optionality::repeats}},
DefaultInt},
{{"a1", OperandInt}, {"a2", OperandInt},
{"a3", OperandInt, Rank::elemental, Optionality::repeats}},
OperandInt},
"max", true, true},
{{"max1",
{{"a1", DefaultReal}, {"a2", DefaultReal},
{"a3", DefaultReal, Rank::elemental, Optionality::repeats}},
DefaultInt},
"max", true, true},
{{"min0",
{{"a1", DefaultInt}, {"a2", DefaultInt},
{"a3", DefaultInt, Rank::elemental, Optionality::repeats}},
DefaultInt},
{{"a1", OperandInt}, {"a2", OperandInt},
{"a3", OperandInt, Rank::elemental, Optionality::repeats}},
OperandInt},
"min", true, true},
{{"min1",
{{"a1", DefaultReal}, {"a2", DefaultReal},
Expand Down Expand Up @@ -3454,6 +3454,9 @@ static DynamicType GetReturnType(const SpecificIntrinsicInterface &interface,
case KindCode::defaultRealKind:
category = TypeCategory::Real;
break;
case KindCode::operand:
category = TypeCategory::Integer;
break;
default:
CRASH_NO_CASE;
}
Expand Down
24 changes: 24 additions & 0 deletions flang/test/Evaluate/bug132646.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
! RUN: %flang %s -o %t && %t | FileCheck %s

program main
print *,kind(max0(1_1,2_1))
print *,kind(max0(1_2,2_2))
print *,kind(max0(1_4,2_4))
print *,kind(max0(1_8,2_8))

print *,kind(min0(1_1,2_1))
print *,kind(min0(1_2,2_2))
print *,kind(min0(1_4,2_4))
print *,kind(min0(1_8,2_8))
end program main

! CHECK: 1
! CHECK-NEXT: 2
! CHECK-NEXT: 4
! CHECK-NEXT: 8

! CHECK-NEXT: 1
! CHECK-NEXT: 2
! CHECK-NEXT: 4
! CHECK-NEXT: 8

4 changes: 1 addition & 3 deletions flang/test/Evaluate/folding04.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ module specific_extremums
! specified for f18 (converting the result).
integer(8), parameter :: max_i32_8 = 2_8**31-1
integer, parameter :: expected_min0 = int(min(max_i32_8, 2_8*max_i32_8), 4)
!WARN: portability: Argument types do not match specific intrinsic 'min0' requirements; using 'min' generic instead and converting the result to INTEGER(4) if needed [-Wuse-generic-intrinsic-when-specific-doesnt-match]
integer, parameter :: result_min0 = min0(max_i32_8, 2_8*max_i32_8)
! result_min0 would be -2 if arguments were converted to default integer.
integer(8), parameter :: result_min0 = min0(max_i32_8, 2_8*max_i32_8)
logical, parameter :: test_min0 = expected_min0 .EQ. result_min0

real, parameter :: expected_amax0 = real(max(max_i32_8, 2_8*max_i32_8), 4)
Expand Down
Loading