diff --git a/flang/test/Semantics/call03.f90 b/flang/test/Semantics/call03.f90 --- a/flang/test/Semantics/call03.f90 +++ b/flang/test/Semantics/call03.f90 @@ -153,7 +153,7 @@ 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 --- a/flang/test/Semantics/case01.f90 +++ b/flang/test/Semantics/case01.f90 @@ -129,7 +129,8 @@ 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 @@ 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 --- a/flang/test/Semantics/common-blocks.f90 +++ b/flang/test/Semantics/common-blocks.f90 @@ -7,7 +7,7 @@ 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 @@ -19,5 +19,6 @@ common /b/ xb, yb equivalence (yb, yb_eq) !ERROR: Multiple initialization of COMMON block /b/ + !WARNING: Blank COMMON object 'x' in a DATA statement is not standard data x /66./, xa /66./, yb_eq /66./ end subroutine diff --git a/flang/test/Semantics/data06.f90 b/flang/test/Semantics/data06.f90 --- a/flang/test/Semantics/data06.f90 +++ b/flang/test/Semantics/data06.f90 @@ -42,6 +42,7 @@ procedure(rfunc), pointer :: rpp real, target :: rt !ERROR: Data object 'rt' may not be used to initialize 'rpp', which is a procedure pointer + !WARNING: Procedure pointer 'rpp' in a DATA statement is not standard data rpp/rt/ !ERROR: Initializer for 'rt' must not be a pointer data rt/null()/ diff --git a/flang/test/Semantics/dosemantics02.f90 b/flang/test/Semantics/dosemantics02.f90 --- a/flang/test/Semantics/dosemantics02.f90 +++ b/flang/test/Semantics/dosemantics02.f90 @@ -23,10 +23,12 @@ 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 --- a/flang/test/Semantics/dosemantics12.f90 +++ b/flang/test/Semantics/dosemantics12.f90 @@ -392,6 +392,7 @@ 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 @@ 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 --- a/flang/test/Semantics/forall01.f90 +++ b/flang/test/Semantics/forall01.f90 @@ -42,6 +42,7 @@ forall(i=1:10) forall(j=1:10) !ERROR: Cannot redefine FORALL variable 'i' + !WARNING: FORALL index variable 'j' not used on left-hand side of assignment i = 1 end forall end forall @@ -81,14 +82,18 @@ 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 @@ 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 --- 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 --- a/flang/test/Semantics/resolve11.f90 +++ b/flang/test/Semantics/resolve11.f90 @@ -4,7 +4,7 @@ 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 --- 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 @@ 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 @@ 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/resolve59.f90 b/flang/test/Semantics/resolve59.f90 --- a/flang/test/Semantics/resolve59.f90 +++ b/flang/test/Semantics/resolve59.f90 @@ -59,9 +59,11 @@ 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/test_errors.py b/flang/test/Semantics/test_errors.py --- a/flang/test/Semantics/test_errors.py +++ b/flang/test/Semantics/test_errors.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -"""Compiles a source file and checks errors against those listed in the file. +"""Compiles a source file and checks errors and warnings against those + listed in the file. Parameters: sys.argv[1]: a source file with contains the input and expected output @@ -19,8 +20,10 @@ srcdir = cm.set_source(sys.argv[1]) with open(srcdir, 'r') as f: src = f.readlines() -actual = "" -expect = "" +err_actual = "" +err_expect = "" +warn_actual = "" +warn_expect = "" diffs = "" log = "" @@ -34,6 +37,7 @@ try: proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, universal_newlines=True, cwd=tmpdir) + log = proc.stderr except subprocess.CalledProcessError as e: log = e.stderr if e.returncode >= 128: @@ -44,25 +48,42 @@ for line in log.split('\n'): m = re.search(r"[^:]*:(\d+:).*(?:error:)(.*)", line) if m: - actual += m.expand(r"\1\2\n") + err_actual += m.expand(r"\1\2\n") +for line in log.split('\n'): + m = re.search(r"[^:]*:(\d+:).*(?:warning:|portability:)(.*)", line) + if m: + warn_actual += m.expand(r"\1\2\n") -# Gets the expected errors and their line number +# Gets the expected diagnostics and their line number errors = [] +warnings = [] for i, line in enumerate(src, 1): - m = re.search(r"(?:^\s*!\s*ERROR: )(.*)", line) - if m: - errors.append(m.group(1)) + me = re.search(r"(?:^\s*!\s*ERROR: )(.*)", line) + mw = re.search(r"(?:^\s*!\s*WARNING: )(.*)", line) + if me: + errors.append(me.group(1)) + continue + if mw: + warnings.append(mw.group(1)) continue if errors: for x in errors: - expect += f"{i}: {x}\n" + err_expect += f"{i}: {x}\n" errors = [] + if warnings: + for x in warnings: + warn_expect += f"{i}: {x}\n" + warnings = [] -# Compares the expected errors with the compiler errors -for line in unified_diff(actual.split("\n"), expect.split("\n"), n=0): +# Compares the expected errors and warnings with the compiler diagnostics +for line in unified_diff(err_actual.split("\n"), err_expect.split("\n"), n=0): line = re.sub(r"(^\-)(\d+:)", r"\nactual at \g<2>", line) line = re.sub(r"(^\+)(\d+:)", r"\nexpect at \g<2>", line) diffs += line +for line in unified_diff(warn_actual.split("\n"), warn_expect.split("\n"), n=0): + line = re.sub(r"(^\-)(\d+:)", r"\nactual warning at \g<2>", line) + line = re.sub(r"(^\+)(\d+:)", r"\nexpected warning at \g<2>", line) + diffs += line if diffs != "": print(diffs)