[flang-commits] [PATCH] D124544: [flang] Downgrade a fatal error to a warning
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Apr 27 11:34:28 PDT 2022
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
A non-CHARACTER expression in a CASE statement is allowed to have
a distinct kind (not type) from the expression in its SELECT CASE.
If a value in a CASE statement is out of range for the SELECT CASE
type, emit a warning, but it should not be a fatal error.
https://reviews.llvm.org/D124544
Files:
flang/lib/Semantics/check-case.cpp
flang/test/Semantics/case01.f90
Index: flang/test/Semantics/case01.f90
===================================================================
--- flang/test/Semantics/case01.f90
+++ flang/test/Semantics/case01.f90
@@ -182,13 +182,13 @@
integer :: j
select case(1_1)
case (127)
- !ERROR: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression
+ !WARN: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression
case (128)
- !ERROR: CASE value (129_4) overflows type (INTEGER(1)) of SELECT CASE expression
- !ERROR: 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
+ !WARN: CASE value (130_4) overflows type (INTEGER(1)) of SELECT CASE expression
case (129:130)
- !ERROR: CASE value (-130_4) overflows type (INTEGER(1)) of SELECT CASE expression
- !ERROR: 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
+ !WARN: 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
Index: flang/lib/Semantics/check-case.cpp
===================================================================
--- flang/lib/Semantics/check-case.cpp
+++ flang/lib/Semantics/check-case.cpp
@@ -94,7 +94,7 @@
return value;
} else {
context_.Say(expr.source,
- "CASE value (%s) overflows type (%s) of SELECT CASE expression"_err_en_US,
+ "CASE value (%s) overflows type (%s) of SELECT CASE expression"_warn_en_US,
folded.AsFortran(), caseExprType_.AsFortran());
hasErrors_ = true;
return std::nullopt;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124544.425582.patch
Type: text/x-patch
Size: 1838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220427/fb5933a1/attachment.bin>
More information about the flang-commits
mailing list