Warn that scoped enumerations are a C++11 extenstion when compiling in

C++98 mode.  This improves on the previous diagnostic message of:

error: expected identifier or '{'
llvm-svn: 180076
This commit is contained in:
Richard Trieu 2013-04-23 02:47:36 +00:00
parent 7467f06533
commit d0d87b5972
3 changed files with 7 additions and 3 deletions

View File

@ -688,6 +688,8 @@ def err_duplicate_virt_specifier : Error<
def err_scoped_enum_missing_identifier : Error<
"scoped enumeration requires a name">;
def ext_scoped_enum : ExtWarn<
"scoped enumerations are a C++11 extension">, InGroup<CXX11>;
def warn_cxx98_compat_scoped_enum : Warning<
"scoped enumerations are incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;

View File

@ -3367,9 +3367,9 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
bool IsScopedUsingClassTag = false;
// In C++11, recognize 'enum class' and 'enum struct'.
if (getLangOpts().CPlusPlus11 &&
(Tok.is(tok::kw_class) || Tok.is(tok::kw_struct))) {
Diag(Tok, diag::warn_cxx98_compat_scoped_enum);
if (Tok.is(tok::kw_class) || Tok.is(tok::kw_struct)) {
Diag(Tok, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_scoped_enum
: diag::ext_scoped_enum);
IsScopedUsingClassTag = Tok.is(tok::kw_class);
ScopedEnumKWLoc = ConsumeToken();

View File

@ -5,3 +5,5 @@ long long ll1 = // expected-warning {{'long long' is a C++11 extension}}
unsigned long long ull1 = // expected-warning {{'long long' is a C++11 extension}}
42ULL; // expected-warning {{'long long' is a C++11 extension}}
enum struct E1 { A, B }; // expected-warning {{scoped enumerations are a C++11 extension}}
enum class E2 { C, D }; // expected-warning {{scoped enumerations are a C++11 extension}}