diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 0f46b16..838fcc9 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -2041,9 +2041,30 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
   TypeResult BaseType;
 
   if (getLang().CPlusPlus0x && Tok.is(tok::colon)) {
+    TentativeParsingAction TPA(*this);
     ConsumeToken();
-    SourceRange Range;
-    BaseType = ParseTypeName(&Range);
+
+    bool PossibleBitfield = false;
+
+    if (getCurScope()->getFlags() & Scope::ClassScope) {
+      // We are in class scope, this can either be an enum declaration with an
+      // underlying type, or a declaration of a bitfield member. We
+      // disambiguate by considering anything that's a simple-type-specifier
+      // followed by '(' as an expression. This suffices because function types
+      // are not valid underlying types anyway.
+      //
+      // If this looks like an expression, just leave it alone and let the
+      // member parser handle it.
+      // FIXME: Improve diagnostic if this is function type.
+      PossibleBitfield = isCXXDeclarationSpecifier() != TPResult::True();
+    }
+
+    if (!PossibleBitfield) {
+      TPA.Commit();
+      SourceRange Range;
+      BaseType = ParseTypeName(&Range);
+    }
+    else TPA.Revert();
   }
 
   // There are three options here.  If we have 'enum foo;', then this is a
diff --git a/test/SemaCXX/enum-bitfield.cpp b/test/SemaCXX/enum-bitfield.cpp
new file mode 100644
index 0000000..fb37f3f
--- /dev/null
+++ b/test/SemaCXX/enum-bitfield.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++0x -verify -triple x86_64-apple-darwin %s
+
+enum E {};
+
+struct Z {};
+
+struct X {
+  enum E : 1;
+  enum E : Z; // expected-error{{invalid underlying type}}
+};
+
+struct Y {
+  enum E : int(2);
+  enum E : Z(); // expected-error{{not an integer constant}}
+};
-- 
1.7.2.2

