]> granicus.if.org Git - clang/commitdiff
Workaround for PR3173. The fix is correct in the sense that if the enum
authorEli Friedman <eli.friedman@gmail.com>
Mon, 8 Dec 2008 02:21:03 +0000 (02:21 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 8 Dec 2008 02:21:03 +0000 (02:21 +0000)
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.

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

lib/AST/ExprConstant.cpp
test/Sema/enum.c

index 9eeaa868a59e297a27f86e4610e360d996007898..341baeab85ba1acd0382a118a16c41fc7ac49bf1 100644 (file)
@@ -430,6 +430,9 @@ bool IntExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
   // 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;
   }
   
index b06882b4d349ea7973a182307d108751592ccb9c..5782a43242eb4d491aa0812017d55d00ca373bf1 100644 (file)
@@ -55,3 +55,6 @@ enum someenum {};  // expected-warning {{use of empty enum extension}}
 enum e0 { // expected-note {{previous definition is here}}
   E0 = sizeof(enum e0 { E1 }) // expected-error {{nested redefinition}}
 };
+
+// PR3173
+enum { PR3173A, PR3173B = PR3173A+50 };