[flang-commits] [flang] 84c6dc9 - [flang] Downgrade a fatal error to a warning

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Apr 27 12:38:35 PDT 2022


Author: Peter Klausler
Date: 2022-04-27T12:31:58-07:00
New Revision: 84c6dc96accc6a0818f196b1a09c9696354a4c19

URL: https://github.com/llvm/llvm-project/commit/84c6dc96accc6a0818f196b1a09c9696354a4c19
DIFF: https://github.com/llvm/llvm-project/commit/84c6dc96accc6a0818f196b1a09c9696354a4c19.diff

LOG: [flang] Downgrade a fatal error to a warning

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.

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

Added: 
    

Modified: 
    flang/lib/Semantics/check-case.cpp
    flang/test/Semantics/case01.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index 4e37f4e1c5e3c..5bc166ef21262 100644
--- a/flang/lib/Semantics/check-case.cpp
+++ b/flang/lib/Semantics/check-case.cpp
@@ -94,7 +94,7 @@ template <typename T> class CaseValues {
               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;

diff  --git a/flang/test/Semantics/case01.f90 b/flang/test/Semantics/case01.f90
index 020f25119b708..7e2d1efa34585 100644
--- a/flang/test/Semantics/case01.f90
+++ b/flang/test/Semantics/case01.f90
@@ -182,13 +182,13 @@ program test_overflow
   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


        


More information about the flang-commits mailing list