[cfe-commits] r126752 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/enum-scoped.cpp

Douglas Gregor dgregor at apple.com
Tue Mar 1 09:16:20 PST 2011


Author: dgregor
Date: Tue Mar  1 11:16:20 2011
New Revision: 126752

URL: http://llvm.org/viewvc/llvm-project?rev=126752&view=rev
Log:
Implement comparison of C++0x scoped enumeration types. Fixes PR9333.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaCXX/enum-scoped.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=126752&r1=126751&r2=126752&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar  1 11:16:20 2011
@@ -7024,6 +7024,12 @@
       ImpCastExprToType(rex, T, CK_BitCast);
       return ResultTy;
     }
+
+    // Handle scoped enumeration types specifically, since they don't promote
+    // to integers.
+    if (lex->getType()->isEnumeralType() &&
+        Context.hasSameUnqualifiedType(lex->getType(), rex->getType()))
+      return ResultTy;
   }
 
   // Handle block pointer types.
@@ -7123,6 +7129,7 @@
     ImpCastExprToType(lex, rType, CK_NullToPointer);
     return ResultTy;
   }
+
   return InvalidOperands(Loc, lex, rex);
 }
 

Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=126752&r1=126751&r2=126752&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Tue Mar  1 11:16:20 2011
@@ -103,3 +103,9 @@
 
 enum : long x; // expected-error{{unnamed enumeration must be a definition}} \
 // expected-warning{{declaration does not declare anything}}
+
+void PR9333() {
+  enum class scoped_enum { yes, no, maybe };
+  scoped_enum e = scoped_enum::yes;
+  if (e == scoped_enum::no) { }
+}





More information about the cfe-commits mailing list