[flang-commits] [flang] 4c549a0 - [flang][NFC] Make semantics test dosemantics03.f90 warning-correct
Emil Kieri via flang-commits
flang-commits at lists.llvm.org
Thu May 26 06:23:56 PDT 2022
Author: Emil Kieri
Date: 2022-05-26T15:22:51+02:00
New Revision: 4c549a0b593e787ac2431ecbcf50b5a5de795f0c
URL: https://github.com/llvm/llvm-project/commit/4c549a0b593e787ac2431ecbcf50b5a5de795f0c
DIFF: https://github.com/llvm/llvm-project/commit/4c549a0b593e787ac2431ecbcf50b5a5de795f0c.diff
LOG: [flang][NFC] Make semantics test dosemantics03.f90 warning-correct
This is a preparation for D125804, which makes test_errors.py test
warnings the same way it already tests errors, i.e., assert that the
emitted and expected errors are identical. The following changes are
made to the test:
- Add the WARNING directive where warnings are expected.
- Remove -Werror in the RUN line. It does not serve much purpose here:
with -Werror flang makes compilation fail in the presence of
warnings, but warnings are still printed as warnings and not as
errors. And I anyway find it better to test the warnings as warnings
instead of promoting them and test both warnings and errors as
errors.
- Update the header comment describing the test case, mostly in
response to the removal of -Werror.
- Remove the reference to 'issue 458', referring to
https://github.com/flang-compiler/f18/issues/458, from the header.
I think the relevant reference here is to C1120 of the standard,
and references to bug trackers from other projects (from before
upstreaming) can be confusing.
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D126176
Added:
Modified:
flang/test/Semantics/dosemantics03.f90
Removed:
################################################################################
diff --git a/flang/test/Semantics/dosemantics03.f90 b/flang/test/Semantics/dosemantics03.f90
index 59c8ddaadeff5..0d2664062cbb0 100644
--- a/flang/test/Semantics/dosemantics03.f90
+++ b/flang/test/Semantics/dosemantics03.f90
@@ -1,15 +1,14 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
-
-! Issue 458 -- semantic checks for a normal DO loop. The DO variable
-! and the initial, final, and step expressions must be INTEGER if the
-! options for standard conformance and turning warnings into errors
-! are both in effect. This test turns on the options for standards
-! conformance and turning warnings into errors. This produces error
-! messages for the cases where REAL and DOUBLE PRECISION variables
-! and expressions are used in the DO controls.
-
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
+!
! C1120 -- DO variable (and associated expressions) must be INTEGER.
! This is extended by allowing REAL and DOUBLE PRECISION
+!
+! The standard requires the DO variable and the initial, final, and step
+! expressions to be INTEGER. As an extension, we do however allow them to be
+! REAL or DOUBLE PRECISION. This test turns on the option for standard
+! conformance checking to test that we get portability warnings for these
+! cases. We also check that other types, such as CHARACTER and LOGICAL, yield
+! errors when used in the DO controls.
MODULE share
INTEGER :: intvarshare
@@ -51,11 +50,13 @@ END FUNCTION ifunc
END DO
! REAL DO variable
+!WARNING: DO controls should be INTEGER
DO rvar = 1, 10, 3
PRINT *, "rvar is: ", rvar
END DO
! DOUBLE PRECISISON DO variable
+!WARNING: DO controls should be INTEGER
DO dvar = 1, 10, 3
PRINT *, "dvar is: ", dvar
END DO
@@ -68,12 +69,14 @@ END FUNCTION ifunc
! Pointer to REAL DO variable
ALLOCATE(prvar)
+!WARNING: DO controls should be INTEGER
DO prvar = 1, 10, 3
PRINT *, "prvar is: ", prvar
END DO
! Pointer to DOUBLE PRECISION DO variable
ALLOCATE(pdvar)
+!WARNING: DO controls should be INTEGER
DO pdvar = 1, 10, 3
PRINT *, "pdvar is: ", pdvar
END DO
@@ -145,22 +148,26 @@ END FUNCTION ifunc
END DO
! Shared association REAL DO variable
+!WARNING: DO controls should be INTEGER
DO realvarshare = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Shared association DOUBLE PRECISION DO variable
+!WARNING: DO controls should be INTEGER
DO dpvarshare = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Initial expressions
! REAL initial expression
+!WARNING: DO controls should be INTEGER
DO ivar = rvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! DOUBLE PRECISION initial expression
+!WARNING: DO controls should be INTEGER
DO ivar = dvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
@@ -171,11 +178,13 @@ END FUNCTION ifunc
END DO
! Pointer to REAL initial expression
+!WARNING: DO controls should be INTEGER
DO ivar = prvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to DOUBLE PRECISION initial expression
+!WARNING: DO controls should be INTEGER
DO ivar = pdvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
@@ -212,11 +221,13 @@ END FUNCTION ifunc
! Final expression
! REAL final expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, rvar, 3
PRINT *, "ivar is: ", ivar
END DO
! DOUBLE PRECISION final expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, dvar, 3
PRINT *, "ivar is: ", ivar
END DO
@@ -227,11 +238,13 @@ END FUNCTION ifunc
END DO
! Pointer to REAL final expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, prvar, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to DOUBLE PRECISION final expression
+!WARNING: DO controls should be INTEGER
DO ivar = pdvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
@@ -250,11 +263,13 @@ END FUNCTION ifunc
! Step expression
! REAL step expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, 10, rvar
PRINT *, "ivar is: ", ivar
END DO
! DOUBLE PRECISION step expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, 10, dvar
PRINT *, "ivar is: ", ivar
END DO
@@ -265,11 +280,13 @@ END FUNCTION ifunc
END DO
! Pointer to REAL step expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, 10, prvar
PRINT *, "ivar is: ", ivar
END DO
! Pointer to DOUBLE PRECISION step expression
+!WARNING: DO controls should be INTEGER
DO ivar = 1, 10, pdvar
PRINT *, "ivar is: ", ivar
END DO
More information about the flang-commits
mailing list