[flang-commits] [clang] [flang] [flang] Warn rather than error on out-of-range constant subscripts (PR #220435)
Andre Kuhlenschmidt via flang-commits
flang-commits at lists.llvm.org
Thu Sep 3 13:54:46 PDT 2026
================
@@ -1,36 +1,39 @@
-! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING %s
-! RUN: not %flang_fc1 -fsyntax-only -Wno-bad-value-in-dead-code %s 2>&1 | FileCheck %s
+! Out-of-range constant subscripts are warnings by default, so use
+! -fno-out-of-bounds-subscripts here to exercise the downgrade of errors to
+! warnings in code that is known at compilation time to be dead.
+! RUN: not %flang_fc1 -fsyntax-only -fno-out-of-bounds-subscripts %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING %s
+! RUN: not %flang_fc1 -fsyntax-only -fno-out-of-bounds-subscripts -Wno-bad-value-in-dead-code %s 2>&1 | FileCheck %s
real a(2)
if (.false.) then
- !CHECK-WARNING::8:12: warning: subscript 3 is greater than upper bound 2 for dimension 1 of array [-Wbad-value-in-dead-code]
+ !CHECK-WARNING::11:12: warning: subscript 3 is greater than upper bound 2 for dimension 1 of array [-Wbad-value-in-dead-code]
print *, a(3)
end if
if (.true.) then
- !CHECK::13:12: error: subscript 0 is less than lower bound 1 for dimension 1 of array
+ !CHECK::16:12: error: subscript 0 is less than lower bound 1 for dimension 1 of array
print *, a(0)
else
- !CHECK-WARNING::16:12: warning: subscript 0 is less than lower bound 1 for dimension 1 of array [-Wbad-value-in-dead-code]
+ !CHECK-WARNING::19:12: warning: subscript 0 is less than lower bound 1 for dimension 1 of array [-Wbad-value-in-dead-code]
print *, a(0)
end if
if (.false.) then
else if (.true.) then
- !CHECK::22:12: error: subscript 0 is less than lower bound 1 for dimension 1 of array
+ !CHECK::25:12: error: subscript 0 is less than lower bound 1 for dimension 1 of array
----------------
akuhlens wrote:
They are all unique error messages and the line info of error messages is checked elsewhere.
https://github.com/llvm/llvm-project/pull/220435
More information about the flang-commits
mailing list