[PATCH] D87595: [flang] Correctly detect overlapping integer cases

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 09:11:08 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGed0abc8ad3f3: [flang] Correctly detect overlapping integer cases (authored by tskeith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87595/new/

https://reviews.llvm.org/D87595

Files:
  flang/include/flang/Evaluate/integer.h
  flang/test/Semantics/case01.f90


Index: flang/test/Semantics/case01.f90
===================================================================
--- flang/test/Semantics/case01.f90
+++ flang/test/Semantics/case01.f90
@@ -163,3 +163,17 @@
    end select
 
 end program
+
+program test_overlap
+  integer :: i
+  !OK: these cases do not overlap
+  select case(i)
+    case(0:)
+    case(:-1)
+  end select
+  select case(i)
+    case(-1:)
+    !ERROR: CASE (:0_4) conflicts with previous cases
+    case(:0)
+  end select
+end
Index: flang/include/flang/Evaluate/integer.h
===================================================================
--- flang/include/flang/Evaluate/integer.h
+++ flang/include/flang/Evaluate/integer.h
@@ -176,22 +176,22 @@
   constexpr Integer &operator=(const Integer &) = default;
 
   constexpr bool operator<(const Integer &that) const {
-    return CompareUnsigned(that) == Ordering::Less;
+    return CompareSigned(that) == Ordering::Less;
   }
   constexpr bool operator<=(const Integer &that) const {
-    return CompareUnsigned(that) != Ordering::Greater;
+    return CompareSigned(that) != Ordering::Greater;
   }
   constexpr bool operator==(const Integer &that) const {
-    return CompareUnsigned(that) == Ordering::Equal;
+    return CompareSigned(that) == Ordering::Equal;
   }
   constexpr bool operator!=(const Integer &that) const {
     return !(*this == that);
   }
   constexpr bool operator>=(const Integer &that) const {
-    return CompareUnsigned(that) != Ordering::Less;
+    return CompareSigned(that) != Ordering::Less;
   }
   constexpr bool operator>(const Integer &that) const {
-    return CompareUnsigned(that) == Ordering::Greater;
+    return CompareSigned(that) == Ordering::Greater;
   }
 
   // Left-justified mask (e.g., MASKL(1) has only its sign bit set)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87595.291588.patch
Type: text/x-patch
Size: 1782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200914/7534d0b2/attachment.bin>


More information about the llvm-commits mailing list