[flang-commits] [flang] 93dca9f - [flang][test] Fix semantics tests with respect to warnings

Emil Kieri via flang-commits flang-commits at lists.llvm.org
Thu Aug 18 10:16:46 PDT 2022


Author: Emil Kieri
Date: 2022-08-18T19:16:20+02:00
New Revision: 93dca9fbeea6c1f83223a621710eaf01c06350db

URL: https://github.com/llvm/llvm-project/commit/93dca9fbeea6c1f83223a621710eaf01c06350db
DIFF: https://github.com/llvm/llvm-project/commit/93dca9fbeea6c1f83223a621710eaf01c06350db.diff

LOG: [flang][test] Fix semantics tests with respect to warnings

Make tests expect the (correctly) emitted warnings using the WARNING
directive. This directive is non-functional now, but will be recognised
by test_errors.py when D125804 is landed. This patch is a preparation
for D125804.

For most tests, we add missing WARNING directives for emitted warnings,
but there are exceptions:

 - for int-literals.f90 and resolve31.f90 we pass -pedantic to the
   frontend driver, so that the expected warnings are actually emitted.

 - for block-data01.f90 and resolve42.f90 we change the tests so that
   warnings, which appear unintentional, are not emitted. While testing
   the warning in question (padding added for alignment in common block)
   would be desired, that is beyond the scope of this patch. This
   warning is target-dependent.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D131987

Added: 
    

Modified: 
    flang/test/Semantics/bindings01.f90
    flang/test/Semantics/block-data01.f90
    flang/test/Semantics/call03.f90
    flang/test/Semantics/case01.f90
    flang/test/Semantics/common-blocks.f90
    flang/test/Semantics/data06.f90
    flang/test/Semantics/dosemantics02.f90
    flang/test/Semantics/dosemantics12.f90
    flang/test/Semantics/forall01.f90
    flang/test/Semantics/int-literals.f90
    flang/test/Semantics/resolve11.f90
    flang/test/Semantics/resolve31.f90
    flang/test/Semantics/resolve35.f90
    flang/test/Semantics/resolve42.f90
    flang/test/Semantics/resolve59.f90
    flang/test/Semantics/resolve85.f90

Removed: 
    


################################################################################
diff  --git a/flang/test/Semantics/bindings01.f90 b/flang/test/Semantics/bindings01.f90
index 75c3544842ba..27a6d57ede71 100644
--- a/flang/test/Semantics/bindings01.f90
+++ b/flang/test/Semantics/bindings01.f90
@@ -3,6 +3,7 @@
 ! and C733, C734 and C779, C780, C782, C783, C784, and C785.
 
 module m
+  !WARNING: A derived type with the BIND attribute is empty
   !ERROR: An ABSTRACT derived type must be extensible
   type, abstract, bind(c) :: badAbstract1
   end type
@@ -44,6 +45,7 @@ module m
   end type
   type, extends(intermediate) :: concrete2  ! ensure no false missing binding error
   end type
+  !WARNING: A derived type with the BIND attribute is empty
   type, bind(c) :: inextensible1
   end type
   !ERROR: The parent type is not extensible

diff  --git a/flang/test/Semantics/block-data01.f90 b/flang/test/Semantics/block-data01.f90
index 5f69aa65d260..4c8b8b7bf8bb 100644
--- a/flang/test/Semantics/block-data01.f90
+++ b/flang/test/Semantics/block-data01.f90
@@ -11,7 +11,7 @@ block data foo
   procedure(sin), pointer :: q => cos
   !ERROR: 'p' may not be a procedure as it is in a COMMON block
   procedure(sin), pointer :: p => cos
-  common /block/ pi, p
+  common /block/ p, pi
   !ERROR: An initialized variable in BLOCK DATA must be in a COMMON block
   integer :: inDataButNotCommon
   data inDataButNotCommon /1/

diff  --git a/flang/test/Semantics/call03.f90 b/flang/test/Semantics/call03.f90
index 7627608de36b..511c2d3d1011 100644
--- a/flang/test/Semantics/call03.f90
+++ b/flang/test/Semantics/call03.f90
@@ -165,7 +165,7 @@ subroutine test06 ! 15.5.2.4(4)
     character :: ch1
     !ERROR: Actual argument variable length '1' is less than expected length '2'
     call ch2(ch1)
-    !WARN: Actual argument expression length '0' is less than expected length '2'
+    !WARNING: Actual argument expression length '0' is less than expected length '2'
     call ch2("")
     call pdtdefault(vardefault)
     call pdtdefault(var3)

diff  --git a/flang/test/Semantics/case01.f90 b/flang/test/Semantics/case01.f90
index fcf91e85a757..15bc30498ab5 100644
--- a/flang/test/Semantics/case01.f90
+++ b/flang/test/Semantics/case01.f90
@@ -129,7 +129,8 @@ program selectCaseProg
   end select
 
   select case (grade2)
-     case (51:50) ! warning
+     !WARNING: CASE has lower bound greater than upper bound
+     case (51:50)
      case (100:)
      case (:30)
      case (40)
@@ -182,13 +183,13 @@ subroutine test_overflow
   integer :: j
   select case(1_1)
   case (127)
-  !WARN: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression
   case (128)
-  !WARN: CASE value (129_4) overflows type (INTEGER(1)) of SELECT CASE expression
-  !WARN: CASE value (130_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (129_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (130_4) overflows type (INTEGER(1)) of SELECT CASE expression
   case (129:130)
-  !WARN: CASE value (-130_4) overflows type (INTEGER(1)) of SELECT CASE expression
-  !WARN: CASE value (-129_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (-130_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (-129_4) overflows type (INTEGER(1)) of SELECT CASE expression
   case (-130:-129)
   case (-128)
   !ERROR: Must be a scalar value, but is a rank-1 array

diff  --git a/flang/test/Semantics/common-blocks.f90 b/flang/test/Semantics/common-blocks.f90
index fccd48d67ee3..89d9fb6e6af0 100644
--- a/flang/test/Semantics/common-blocks.f90
+++ b/flang/test/Semantics/common-blocks.f90
@@ -7,7 +7,7 @@ subroutine init_1
   common x, y
   common /a/ xa, ya
   common /b/ xb, yb
-  !CHECK: portability: Blank COMMON object 'x' in a DATA statement is not standard
+  !WARNING: Blank COMMON object 'x' in a DATA statement is not standard
   data x /42./, xa /42./, yb/42./
 end subroutine
 
@@ -18,6 +18,7 @@ subroutine init_conflict
   common /a/ xa, ya
   common /b/ xb, yb
   equivalence (yb, yb_eq)
+  !WARNING: Blank COMMON object 'x' in a DATA statement is not standard
   !ERROR: Multiple initialization of COMMON block /b/
   data x /66./, xa /66./, yb_eq /66./
 end subroutine

diff  --git a/flang/test/Semantics/data06.f90 b/flang/test/Semantics/data06.f90
index 08cdd147a084..052372afe544 100644
--- a/flang/test/Semantics/data06.f90
+++ b/flang/test/Semantics/data06.f90
@@ -41,6 +41,7 @@ real function rfunc(x)
   data rp/rfunc/
   procedure(rfunc), pointer :: rpp
   real, target :: rt
+  !WARNING: Procedure pointer 'rpp' in a DATA statement is not standard
   !ERROR: Data object 'rt' may not be used to initialize 'rpp', which is a procedure pointer
   data rpp/rt/
   !ERROR: Initializer for 'rt' must not be a pointer

diff  --git a/flang/test/Semantics/dosemantics02.f90 b/flang/test/Semantics/dosemantics02.f90
index 563736b721cc..d6075a8a3f8f 100644
--- a/flang/test/Semantics/dosemantics02.f90
+++ b/flang/test/Semantics/dosemantics02.f90
@@ -23,10 +23,12 @@ SUBROUTINE s1()
   INTEGER, PARAMETER :: constInt = 0
 
   ! Warn on this one for backwards compatibility
+  !WARNING: DO step expression should not be zero
   DO 10 I = 1, 10, 0
   10 CONTINUE
 
   ! Warn on this one for backwards compatibility
+  !WARNING: DO step expression should not be zero
   DO 20 I = 1, 10, 5 - 5
   20 CONTINUE
 

diff  --git a/flang/test/Semantics/dosemantics12.f90 b/flang/test/Semantics/dosemantics12.f90
index e5a390fa8cb9..fc13aeaf3e04 100644
--- a/flang/test/Semantics/dosemantics12.f90
+++ b/flang/test/Semantics/dosemantics12.f90
@@ -392,6 +392,7 @@ subroutine s12()
 
   call intentInOutSub(jvar, ivar)
   do ivar = 1,10
+    !WARNING: Possible redefinition of DO variable 'ivar'
     call intentInOutSub(jvar, ivar)
   end do
 
@@ -435,8 +436,8 @@ subroutine s13()
     jvar = 83 + intentInFunc(intentOutFunc(ivar))
   end do
 
-  ! Warning for passing a DO variable to an INTENT(INOUT) dummy
   do ivar = 1, 10
+    !WARNING: Possible redefinition of DO variable 'ivar'
     jvar = intentInOutFunc(ivar)
   end do
 

diff  --git a/flang/test/Semantics/forall01.f90 b/flang/test/Semantics/forall01.f90
index 1ace7627abe6..39d2a5c8bd2f 100644
--- a/flang/test/Semantics/forall01.f90
+++ b/flang/test/Semantics/forall01.f90
@@ -41,6 +41,7 @@ subroutine forall3
   end forall
   forall(i=1:10)
     forall(j=1:10)
+      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment
       !ERROR: Cannot redefine FORALL variable 'i'
       i = 1
     end forall
@@ -81,14 +82,18 @@ subroutine forall5
     x(i) = y(i)
   end forall
   forall(i=1:10)
-    x = y  ! warning: i not used on LHS
+    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+    x = y
     forall(j=1:10)
-      x(i) = y(i)  ! warning: j not used on LHS
-      x(j) = y(j)  ! warning: i not used on LHS
+      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment
+      x(i) = y(i)
+      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+      x(j) = y(j)
     endforall
   endforall
   do concurrent(i=1:10)
     x = y
+    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
     forall(i=1:10) x = y
   end do
 end
@@ -101,6 +106,7 @@ subroutine forall6
   real, target :: b(10)
   forall(i=1:10)
     a(i)%p => b(i)
-    a(1)%p => b(i)  ! warning: i not used on LHS
+    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+    a(1)%p => b(i)
   end forall
 end

diff  --git a/flang/test/Semantics/int-literals.f90 b/flang/test/Semantics/int-literals.f90
index 2344d6b9595c..6d4a63e4bba7 100644
--- a/flang/test/Semantics/int-literals.f90
+++ b/flang/test/Semantics/int-literals.f90
@@ -1,4 +1,4 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
 ! Fortran syntax considers signed int literals in complex literals
 ! to be a distinct production, not an application of unary +/- to
 ! an unsigned int literal, so they're used here to test overflow

diff  --git a/flang/test/Semantics/resolve11.f90 b/flang/test/Semantics/resolve11.f90
index 2d93c63212af..33ce88342b49 100644
--- a/flang/test/Semantics/resolve11.f90
+++ b/flang/test/Semantics/resolve11.f90
@@ -4,7 +4,7 @@ module m
   integer, private :: j
   !ERROR: The accessibility of 'i' has already been specified as PUBLIC
   private i
-  !The accessibility of 'j' has already been specified as PRIVATE
+  !WARNING: The accessibility of 'j' has already been specified as PRIVATE
   private j
 end
 

diff  --git a/flang/test/Semantics/resolve31.f90 b/flang/test/Semantics/resolve31.f90
index 8535ebbfa4e3..5f41cbfd5111 100644
--- a/flang/test/Semantics/resolve31.f90
+++ b/flang/test/Semantics/resolve31.f90
@@ -1,4 +1,4 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
 ! C735 If EXTENDS appears, SEQUENCE shall not appear.
 ! C738 The same private-or-sequence shall not appear more than once in a
 ! given derived-type-def .
@@ -49,8 +49,10 @@ module m4
   type :: t1
     private
     sequence
-    private  ! not a fatal error
-    sequence ! not a fatal error
+    !WARNING: PRIVATE may not appear more than once in derived type components
+    private
+    !WARNING: SEQUENCE may not appear more than once in derived type components
+    sequence
     real :: t1Field
   end type
   type :: t1a
@@ -83,7 +85,7 @@ module m4
     class(*), allocatable :: typeStarField
     !ERROR: A sequence type data component must either be of an intrinsic type or a derived sequence type
     type(plainType) :: testField1
-    !Pointers are ok as an extension
+    !WARNING: A sequence type data component that is a pointer to a non-sequence type is not standard
     type(plainType), pointer :: testField1p
     type(sequenceType) :: testField2
     procedure(real), pointer, nopass :: procField

diff  --git a/flang/test/Semantics/resolve35.f90 b/flang/test/Semantics/resolve35.f90
index 1dcfd068b6e7..46a3a92c7c83 100644
--- a/flang/test/Semantics/resolve35.f90
+++ b/flang/test/Semantics/resolve35.f90
@@ -78,6 +78,7 @@ subroutine s7
   do concurrent(integer::i=1:5) local(j, i) &
       !ERROR: 'j' is already declared in this scoping unit
       local_init(k, j) &
+      !WARNING: Variable 'a' with SHARED locality implicitly declared
       shared(a)
     a = j + 1
   end do

diff  --git a/flang/test/Semantics/resolve42.f90 b/flang/test/Semantics/resolve42.f90
index 975bbed8cb4d..5a433d06ccc1 100644
--- a/flang/test/Semantics/resolve42.f90
+++ b/flang/test/Semantics/resolve42.f90
@@ -1,7 +1,7 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
 subroutine s1
-  !ERROR: Array 'z' without ALLOCATABLE or POINTER attribute must have explicit shape
-  common x, y(4), z(:)
+  !ERROR: Array 'x' without ALLOCATABLE or POINTER attribute must have explicit shape
+  common x(:), y(4), z
 end
 
 subroutine s2
@@ -28,9 +28,9 @@ subroutine s5
 end
 
 function f6(x) result(r)
-  !ERROR: Dummy argument 'x' may not appear in a COMMON block
   !ERROR: ALLOCATABLE object 'y' may not appear in a COMMON block
-  common x,y,z
+  !ERROR: Dummy argument 'x' may not appear in a COMMON block
+  common y,x,z
   allocatable y
   !ERROR: Function result 'r' may not appear in a COMMON block
   common r

diff  --git a/flang/test/Semantics/resolve59.f90 b/flang/test/Semantics/resolve59.f90
index 6f9324e36ec0..a79c4a462067 100644
--- a/flang/test/Semantics/resolve59.f90
+++ b/flang/test/Semantics/resolve59.f90
@@ -59,9 +59,11 @@ real function rfunc(x)
     x = acos(f5)
   end function
   ! Sanity test: f18 handles C1560 violation by ignoring RESULT
-  function f6() result(f6) !OKI (warning)
+  !WARNING: The function name should not appear in RESULT, references to 'f6' inside the function will be considered as references to the result only
+  function f6() result(f6)
   end function
-  function f7() result(f7) !OKI (warning)
+  !WARNING: The function name should not appear in RESULT, references to 'f7' inside the function will be considered as references to the result only
+  function f7() result(f7)
     real :: x, f7
     !ERROR: Recursive call to 'f7' requires a distinct RESULT in its declaration
     x = acos(f7())

diff  --git a/flang/test/Semantics/resolve85.f90 b/flang/test/Semantics/resolve85.f90
index d1720bd5aef8..b85b7bb052db 100644
--- a/flang/test/Semantics/resolve85.f90
+++ b/flang/test/Semantics/resolve85.f90
@@ -24,6 +24,7 @@ module m
   end type derived4
 
   !WARNING: Attribute 'BIND(C)' cannot be used more than once
+  !WARNING: A derived type with the BIND attribute is empty
   type, bind(c), public, bind(c) :: derived5
   end type derived5
 


        


More information about the flang-commits mailing list