diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-11-02 01:34:28 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-11-02 01:34:28 +0000 |
commit | cef3a7bf84817c58c7666df9e87199b9a6b8b9a3 (patch) | |
tree | 5643463f1af269bf8413dd7309a8635fb010eaea | |
parent | e579328ec9a95acc7f181e04c58a747ba001d80f (diff) |
Change diagnostics for enums with fixed underlying type so in C++98 mode, we cite C++11.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167273 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 7 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 11 | ||||
-rw-r--r-- | test/SemaCXX/MicrosoftExtensions.cpp | 6 |
3 files changed, 15 insertions, 9 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 235b2da62f..929835a2ca 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -86,8 +86,11 @@ 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">, +def ext_cxx11_enum_fixed_underlying_type : Extension< + "enumeration types with a fixed underlying type are a C++11 extension">, + InGroup<CXX11>; +def ext_c_enum_fixed_underlying_type : Extension< + "enumeration types with a fixed underlying type are a Microsoft extension">, InGroup<Microsoft>; def warn_cxx98_compat_enum_fixed_underlying_type : Warning< "enumeration types with a fixed underlying type are incompatible with C++98">, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index bb5f333749..7b4fbfc287 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3233,11 +3233,14 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, SourceRange Range; BaseType = ParseTypeName(&Range); - if (!getLangOpts().CPlusPlus0x && !getLangOpts().ObjC2) - Diag(StartLoc, diag::ext_ms_enum_fixed_underlying_type) - << Range; - if (getLangOpts().CPlusPlus0x) + if (getLangOpts().CPlusPlus0x) { Diag(StartLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type); + } else if (!getLangOpts().ObjC2) { + if (getLangOpts().CPlusPlus) + Diag(StartLoc, diag::ext_cxx11_enum_fixed_underlying_type) << Range; + else + Diag(StartLoc, diag::ext_c_enum_fixed_underlying_type) << Range; + } } } diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index 9b50d3d28b..6b43ea205a 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions +// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions // ::type_info is predeclared with forward class declartion @@ -112,11 +112,11 @@ 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 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}} enum E1 : seventeen; }; -enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} +enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}} SomeValue = 0x100000000 }; |