]> granicus.if.org Git - clang/commitdiff
PR17103: Scoped enumerations with signed integer types have signed integer
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 4 Sep 2013 23:34:21 +0000 (23:34 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 4 Sep 2013 23:34:21 +0000 (23:34 +0000)
representation. Don't emit comparisons on them as 'icmp ult'!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190010 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Type.cpp
test/CodeGenCXX/scoped-enums.cpp

index b848d3a2247109d44e24c5b1846a4bc759875889..8027f52216fcbfe99efb14d8b6c8fc7329c53209 100644 (file)
@@ -738,9 +738,9 @@ bool Type::isSignedIntegerOrEnumerationType() const {
 
 bool Type::hasSignedIntegerRepresentation() const {
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
-    return VT->getElementType()->isSignedIntegerType();
+    return VT->getElementType()->isSignedIntegerOrEnumerationType();
   else
-    return isSignedIntegerType();
+    return isSignedIntegerOrEnumerationType();
 }
 
 /// isUnsignedIntegerType - Return true if this is an integer type that is
@@ -778,9 +778,9 @@ bool Type::isUnsignedIntegerOrEnumerationType() const {
 
 bool Type::hasUnsignedIntegerRepresentation() const {
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
-    return VT->getElementType()->isUnsignedIntegerType();
+    return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
   else
-    return isUnsignedIntegerType();
+    return isUnsignedIntegerOrEnumerationType();
 }
 
 bool Type::isFloatingType() const {
index c20faaaf2e96d02f718e89af042753430c7fb4ba..159172d1662e716da23feb62b670591c293e51cd 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
 
 // PR9923
 enum class Color { red, blue, green };
@@ -15,3 +15,10 @@ void h(Colour);
 void i() {
   h(Colour::grey);
 }
+
+enum struct PR17103 : int { a = -1, b = 1 };
+bool cmp(PR17103 x, PR17103 y) { return x < y; }
+
+// CHECK-LABEL: @_Z3cmp7PR17103S_(
+// CHECK-NOT: }
+// CHECK: icmp slt