[cfe-commits] r60680 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/enum.c

Eli Friedman eli.friedman at gmail.com
Sun Dec 7 18:21:03 PST 2008


Author: efriedma
Date: Sun Dec  7 20:21:03 2008
New Revision: 60680

URL: http://llvm.org/viewvc/llvm-project?rev=60680&view=rev
Log:
Workaround for PR3173.  The fix is correct in the sense that if the enum 
code were working correctly, it would be a no-op, but it's not really a 
proper fix.  That said, I don't really want to touch the enum code at 
the moment because I don't understand it very well, and this seems to 
be a relatively visible regression.


Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/Sema/enum.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=60680&r1=60679&r2=60680&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Dec  7 20:21:03 2008
@@ -430,6 +430,9 @@
   // Enums are integer constant exprs.
   if (const EnumConstantDecl *D = dyn_cast<EnumConstantDecl>(E->getDecl())) {
     Result = D->getInitVal();
+    // FIXME: This is an ugly hack around the fact that enums don't set their
+    // signedness consistently; see PR3173
+    Result.setIsUnsigned(!E->getType()->isSignedIntegerType());
     return true;
   }
   

Modified: cfe/trunk/test/Sema/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=60680&r1=60679&r2=60680&view=diff

==============================================================================
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Sun Dec  7 20:21:03 2008
@@ -55,3 +55,6 @@
 enum e0 { // expected-note {{previous definition is here}}
   E0 = sizeof(enum e0 { E1 }) // expected-error {{nested redefinition}}
 };
+
+// PR3173
+enum { PR3173A, PR3173B = PR3173A+50 };





More information about the cfe-commits mailing list