From 0d0355abfca92056d783f850128ddf1c066fc414 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 2 Nov 2012 01:34:28 +0000 Subject: [PATCH] Change diagnostics for enums with fixed underlying type so in C++98 mode, we cite C++11. llvm-svn: 167273 --- clang/include/clang/Basic/DiagnosticParseKinds.td | 7 +++++-- clang/lib/Parse/ParseDecl.cpp | 11 +++++++---- clang/test/SemaCXX/MicrosoftExtensions.cpp | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 235b2da..929835a 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/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; +def ext_c_enum_fixed_underlying_type : Extension< + "enumeration types with a fixed underlying type are a Microsoft extension">, InGroup; def warn_cxx98_compat_enum_fixed_underlying_type : Warning< "enumeration types with a fixed underlying type are incompatible with C++98">, diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index bb5f333..7b4fbfc2 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/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/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp index 9b50d3d..6b43ea2 100644 --- a/clang/test/SemaCXX/MicrosoftExtensions.cpp +++ b/clang/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 }; -- 2.7.4