After parsing a ':' in an enum-specifier within class context,
disambiguate between an expression (for a bit-field width) and a type
(for a fixed underlying type). Since the disambiguation can be
expensive (due to tentative parsing), we perform a simplistic
disambiguation based on one-token lookahead before going into the
full-blown tentative parsing. Based on a patch by Daniel Wallin.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120582 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/enum-bitfield.cpp b/test/SemaCXX/enum-bitfield.cpp
new file mode 100644
index 0000000..a766116
--- /dev/null
+++ b/test/SemaCXX/enum-bitfield.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++0x -verify -triple x86_64-apple-darwin %s
+
+enum E {};
+
+struct Z {};
+typedef int Integer;
+
+struct X {
+  enum E : 1;
+  enum E : Z; // expected-error{{invalid underlying type}}
+  enum E2 : int;
+  enum E3 : Integer;
+};
+
+struct Y {
+  enum E : int(2);
+  enum E : Z(); // expected-error{{not an integer constant}}
+};