summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-22 20:32:04 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-22 20:32:04 +0000
commita1aec29a2d09edcc8ef487eddef289e7e6842f16 (patch)
tree67447de84cb61e1f2c6e5c65539c39e9068cefba
parent7a24210ebdcefc1446369ec98f4209a93353335e (diff)
downloadbcm5719-llvm-a1aec29a2d09edcc8ef487eddef289e7e6842f16.tar.gz
bcm5719-llvm-a1aec29a2d09edcc8ef487eddef289e7e6842f16.zip
Enable enumeration types with a fixed underlying type, e.g.,
enum X : long { Value = 0x100000000 }; when in Microsoft-extension mode (-fms-extensions). This (now C++0x) feature has been supported since Microsoft Visual Studio .NET 2003. llvm-svn: 126243
-rw-r--r--clang/include/clang/Basic/DiagnosticParseKinds.td3
-rw-r--r--clang/lib/Parse/ParseDecl.cpp10
-rw-r--r--clang/test/Sema/MicrosoftExtensions.c12
-rw-r--r--clang/test/SemaCXX/MicrosoftExtensions.cpp13
4 files changed, 36 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index fd64e90d739..7e20d20cd23 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -59,6 +59,9 @@ def err_enumerator_list_missing_comma : Error<
"missing ',' between enumerators">;
def err_enumerator_unnamed_no_def : Error<
"unnamed enumeration must be a definition">;
+def ext_ms_enum_fixed_underlying_type : Extension<
+ "enumeration types with a fixed underlying type are a Microsoft extension">,
+ InGroup<Microsoft>;
def ext_gnu_indirect_goto : Extension<
"use of GNU indirect-goto extension">, InGroup<GNU>;
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index d9c5069f598..2999fdf5d4b 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1975,7 +1975,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
}
}
- bool AllowFixedUnderlyingType = getLang().CPlusPlus0x;
+ bool AllowFixedUnderlyingType = getLang().CPlusPlus0x || getLang().Microsoft;
bool IsScopedEnum = false;
bool IsScopedUsingClassTag = false;
@@ -2047,7 +2047,9 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
// Consume the ':'.
ConsumeToken();
- if (isCXXDeclarationSpecifier() != TPResult::True()) {
+ if ((getLang().CPlusPlus &&
+ isCXXDeclarationSpecifier() != TPResult::True()) ||
+ (!getLang().CPlusPlus && !isDeclarationSpecifier(true))) {
// We'll parse this as a bitfield later.
PossibleBitfield = true;
TPA.Revert();
@@ -2064,6 +2066,10 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
if (!PossibleBitfield) {
SourceRange Range;
BaseType = ParseTypeName(&Range);
+
+ if (!getLang().CPlusPlus0x)
+ Diag(StartLoc, diag::ext_ms_enum_fixed_underlying_type)
+ << Range;
}
}
diff --git a/clang/test/Sema/MicrosoftExtensions.c b/clang/test/Sema/MicrosoftExtensions.c
index 0ef72855684..59bf54eb62f 100644
--- a/clang/test/Sema/MicrosoftExtensions.c
+++ b/clang/test/Sema/MicrosoftExtensions.c
@@ -67,3 +67,15 @@ void foo()
var.bad2; // expected-error {{no member named 'bad2' in 'struct test'}}
}
+// Enumeration types with a fixed underlying type.
+const int seventeen = 17;
+typedef int Int;
+
+struct X0 {
+ enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ enum E1 : seventeen;
+};
+
+enum : long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ SomeValue = 0x100000000
+};
diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp
index 2bcbbcaeb52..3592e2760ae 100644
--- a/clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -109,3 +109,16 @@ int main()
f(0xffffffffffffffffLL);
f(0xffffffffffffffffi64);
}
+
+// Enumeration types with a fixed underlying type.
+const int seventeen = 17;
+typedef int Int;
+
+struct X0 {
+ enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ enum E1 : seventeen;
+};
+
+enum : long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ SomeValue = 0x100000000
+};
OpenPOWER on IntegriCloud