Skip to content

Commit fb2b31b

Browse files
committed
--Fix for issue #132646
1 parent 85aaaf6 commit fb2b31b

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

flang/lib/Evaluate/intrinsics.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,19 +1336,19 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
13361336
{{"log", {{"x", DefaultReal}}, DefaultReal}},
13371337
{{"log10", {{"x", DefaultReal}}, DefaultReal}},
13381338
{{"max0",
1339-
{{"a1", DefaultInt}, {"a2", DefaultInt},
1340-
{"a3", DefaultInt, Rank::elemental, Optionality::repeats}},
1341-
DefaultInt},
1339+
{{"a1", OperandInt}, {"a2", OperandInt},
1340+
{"a3", OperandInt, Rank::elemental, Optionality::repeats}},
1341+
OperandInt},
13421342
"max", true, true},
13431343
{{"max1",
13441344
{{"a1", DefaultReal}, {"a2", DefaultReal},
13451345
{"a3", DefaultReal, Rank::elemental, Optionality::repeats}},
13461346
DefaultInt},
13471347
"max", true, true},
13481348
{{"min0",
1349-
{{"a1", DefaultInt}, {"a2", DefaultInt},
1350-
{"a3", DefaultInt, Rank::elemental, Optionality::repeats}},
1351-
DefaultInt},
1349+
{{"a1", OperandInt}, {"a2", OperandInt},
1350+
{"a3", OperandInt, Rank::elemental, Optionality::repeats}},
1351+
OperandInt},
13521352
"min", true, true},
13531353
{{"min1",
13541354
{{"a1", DefaultReal}, {"a2", DefaultReal},
@@ -3454,6 +3454,9 @@ static DynamicType GetReturnType(const SpecificIntrinsicInterface &interface,
34543454
case KindCode::defaultRealKind:
34553455
category = TypeCategory::Real;
34563456
break;
3457+
case KindCode::operand:
3458+
category = TypeCategory::Integer;
3459+
break;
34573460
default:
34583461
CRASH_NO_CASE;
34593462
}

flang/test/Evaluate/bug132646.f90

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %flang %s -o %t && %t | FileCheck %s
2+
3+
program main
4+
print *,kind(max0(1_1,2_1))
5+
print *,kind(max0(1_2,2_2))
6+
print *,kind(max0(1_4,2_4))
7+
print *,kind(max0(1_8,2_8))
8+
9+
print *,kind(min0(1_1,2_1))
10+
print *,kind(min0(1_2,2_2))
11+
print *,kind(min0(1_4,2_4))
12+
print *,kind(min0(1_8,2_8))
13+
end program main
14+
15+
! CHECK: 1
16+
! CHECK-NEXT: 2
17+
! CHECK-NEXT: 4
18+
! CHECK-NEXT: 8
19+
20+
! CHECK-NEXT: 1
21+
! CHECK-NEXT: 2
22+
! CHECK-NEXT: 4
23+
! CHECK-NEXT: 8
24+

flang/test/Evaluate/folding04.f90

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ module specific_extremums
8686
! specified for f18 (converting the result).
8787
integer(8), parameter :: max_i32_8 = 2_8**31-1
8888
integer, parameter :: expected_min0 = int(min(max_i32_8, 2_8*max_i32_8), 4)
89-
!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]
90-
integer, parameter :: result_min0 = min0(max_i32_8, 2_8*max_i32_8)
91-
! result_min0 would be -2 if arguments were converted to default integer.
89+
integer(8), parameter :: result_min0 = min0(max_i32_8, 2_8*max_i32_8)
9290
logical, parameter :: test_min0 = expected_min0 .EQ. result_min0
9391

9492
real, parameter :: expected_amax0 = real(max(max_i32_8, 2_8*max_i32_8), 4)

0 commit comments

Comments
 (0)