r180076 - Warn that scoped enumerations are a C++11 extenstion when compiling in
Eric Christopher
echristo at gmail.com
Tue Apr 23 03:49:50 PDT 2013
woot. Thanks!
-eric
On Tue, Apr 23, 2013 at 3:47 AM, Richard Trieu <rtrieu at google.com> wrote:
> Author: rtrieu
> Date: Mon Apr 22 21:47:36 2013
> New Revision: 180076
>
> URL: http://llvm.org/viewvc/llvm-project?rev=180076&view=rev
> Log:
> 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 '{'
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/test/SemaCXX/warn-c++11-extensions.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=180076&r1=180075&r2=180076&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 22 21:47:36 2013
> @@ -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;
>
> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=180076&r1=180075&r2=180076&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 22 21:47:36 2013
> @@ -3367,9 +3367,9 @@ void Parser::ParseEnumSpecifier(SourceLo
> 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();
>
>
> Modified: cfe/trunk/test/SemaCXX/warn-c++11-extensions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-c%2B%2B11-extensions.cpp?rev=180076&r1=180075&r2=180076&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/warn-c++11-extensions.cpp (original)
> +++ cfe/trunk/test/SemaCXX/warn-c++11-extensions.cpp Mon Apr 22 21:47:36 2013
> @@ -5,3 +5,5 @@ long long ll1 = // expected-warning {{'l
> 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}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list