-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang1] Fix an MIN/MAX intrinsic bug
This patch solves two problems: 1.According to the fortran 2008 standard, add syntax check for MAX/MIN intrinsic, as follows: The arguments shall all be of the same type which shall be integer, real, or character and they shall all have the same kind type parameter. 2.The final type of argument with MIN/MAX intrinsic is determined by the type of highest precision atgument, not the first argument.
- Loading branch information
1 parent
08b46d7
commit 7e03751
Showing
11 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
build: $(SRC)/$(TEST).F90 | ||
@echo ------------------------------------ building test $(TEST) | ||
-$(FC) -c $(SRC)/$(TEST).F90 > $(TEST).rslt 2>&1 | ||
|
||
run: | ||
@echo ------------------------------------ nothing to run for test $(TEST) | ||
|
||
verify: $(TEST).rslt | ||
@echo ------------------------------------ verifying test $(TEST) | ||
$(COMP_CHECK) $(SRC)/$(TEST).F90 $(TEST).rslt $(FC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
build: $(SRC)/$(TEST).F90 | ||
@echo ------------------------------------ building test $(TEST) | ||
-$(FC) -c $(SRC)/$(TEST).F90 > $(TEST).rslt 2>&1 | ||
|
||
run: | ||
@echo ------------------------------------ nothing to run for test $(TEST) | ||
|
||
verify: $(TEST).rslt | ||
@echo ------------------------------------ verifying test $(TEST) | ||
$(COMP_CHECK) $(SRC)/$(TEST).F90 $(TEST).rslt $(FC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
build: $(SRC)/$(TEST).F90 | ||
@echo ------------------------------------ building test $(TEST) | ||
-$(FC) -c $(SRC)/$(TEST).F90 > $(TEST).rslt 2>&1 | ||
|
||
run: | ||
@echo ------------------------------------ nothing to run for test $(TEST) | ||
|
||
verify: $(TEST).rslt | ||
@echo ------------------------------------ verifying test $(TEST) | ||
$(COMP_CHECK) $(SRC)/$(TEST).F90 $(TEST).rslt $(FC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Shared lit script for each tests. Run bash commands that run tests with make. | ||
|
||
# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t | ||
# RUN: cat %t | FileCheck %S/runmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Shared lit script for each tests. Run bash commands that run tests with make. | ||
|
||
# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t | ||
# RUN: cat %t | FileCheck %S/runmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Shared lit script for each tests. Run bash commands that run tests with make. | ||
|
||
# REQUIRES: quadfp | ||
# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t | ||
# RUN: cat %t | FileCheck %S/runmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
! See https://llvm.org/LICENSE.txt for license information. | ||
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
! Test that MIN/MAX intrinsic have not the same kind type parameter. | ||
|
||
program test | ||
real(kind = 4) :: r4 = 1.0 | ||
real(kind = 8) :: r8 = 1.0 | ||
integer(kind = 1) :: i1 = 1 | ||
integer(kind = 2) :: i2 = 1 | ||
integer(kind = 4) :: i4 = 1 | ||
integer(kind = 8) :: i8 = 1 | ||
character(len = 1) :: c = "a" | ||
real :: res | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r4, i1) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r4, i1) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r4, i2) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r4, i2) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r4, i4) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r4, i4) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r4, i8) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r4, i8) | ||
!{error "PGF90-S-0074-Illegal number or type of arguments to max"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r4, c) | ||
!{error "PGF90-S-0074-Illegal number or type of arguments to min"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r4, c) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r8, i1) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r8, i1) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r8, i2) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r8, i2) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r8, i4) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r8, i4) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r8, i8) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r8, i8) | ||
!{error "PGF90-S-0074-Illegal number or type of arguments to max"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r8, c) | ||
!{error "PGF90-S-0074-Illegal number or type of arguments to min"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r8, c) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
! See https://llvm.org/LICENSE.txt for license information. | ||
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
! Test that MIN/MAX intrinsic have not INTEGER, REAL, or CHARACTER arguments. | ||
|
||
program test | ||
complex(kind = 4) :: c1 = 1.0 | ||
complex(kind = 4) :: c2 = 1.0 | ||
logical :: l1 = .true. | ||
logical :: l2 = .true. | ||
real :: res | ||
!{error "PGF90-S-0155-Arguments must be INTEGER, REAL, or CHARACTER!"} | ||
!{error "PGF90-S-0155-Arguments must be INTEGER, REAL, or CHARACTER!"} | ||
res = max(c1, c2) | ||
!{error "PGF90-S-0155-Arguments must be INTEGER, REAL, or CHARACTER!"} | ||
!{error "PGF90-S-0155-Arguments must be INTEGER, REAL, or CHARACTER!"} | ||
res = min(l1, l2) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
! See https://llvm.org/LICENSE.txt for license information. | ||
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
! Test that MIN/MAX intrinsic have not the same kind type parameter. | ||
|
||
program test | ||
real(kind = 16) :: r16 = 1.0 | ||
integer(kind = 1) :: i1 = 1 | ||
integer(kind = 2) :: i2 = 1 | ||
integer(kind = 4) :: i4 = 1 | ||
integer(kind = 8) :: i8 = 1 | ||
character(len = 1) :: c = "a" | ||
real :: res | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r16, i1) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r16, i1) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r16, i2) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r16, i2) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r16, i4) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r16, i4) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r16, i8) | ||
!{warning "PGF90-W-0093-Type conversion of expression performed"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r16, i8) | ||
!{error "PGF90-S-0074-Illegal number or type of arguments to max"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = max(r16, c) | ||
!{error "PGF90-S-0074-Illegal number or type of arguments to min"} | ||
!{error "PGF90-S-0155-Arguments must have the same kind type parameter!"} | ||
res = min(r16, c) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
! | ||
! Part of the LLVM Project, under the Apache License v2.0 with LLVM | ||
! Exceptions. | ||
! See https://llvm.org/LICENSE.txt for license information. | ||
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
! | ||
! Test that MIN/MAX intrinsic have different kind type. | ||
! | ||
! RUN: %flang -emit-llvm -S %s -o %t | ||
! RUN: cat %t | FileCheck %s -check-prefix=CHECK-DTYPE | ||
|
||
! CHECK-DTYPE: fpext float {{%.*}} to double | ||
program test | ||
real(kind = 4) :: r4 = 2.0 | ||
real(kind = 8) :: r8 = 1.0 | ||
real(kind = 8) :: res | ||
res = min(r4, r8) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters