From: Richard Smith Date: Thu, 13 Jun 2013 02:12:17 +0000 (+0000) Subject: In C++11, promote access declaration diagnostic from warning to error. There X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b2209fd149436c98e73d4b8667b40b5f4b974cd;p=clang In C++11, promote access declaration diagnostic from warning to error. There doesn't seem to be any value in even adding a -W flag for this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183882 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 1c9d2955ec..f296c5268a 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -287,6 +287,9 @@ def note_using_decl : Note<"%select{|previous }0using declaration">; def warn_access_decl_deprecated : Warning< "access declarations are deprecated; use using declarations instead">, InGroup; +def err_access_decl : Error< + "ISO C++11 does not allow access declarations; " + "use using declarations instead">; def warn_exception_spec_deprecated : Warning< "dynamic exception specifications are deprecated">, InGroup, DefaultIgnore; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index be198ad378..a4549fb892 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -6742,8 +6742,10 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, // diagnostics. if (!HasUsingKeyword) { UsingLoc = Name.getLocStart(); - - Diag(UsingLoc, diag::warn_access_decl_deprecated) + + Diag(UsingLoc, + getLangOpts().CPlusPlus11 ? diag::err_access_decl + : diag::warn_access_decl_deprecated) << FixItHint::CreateInsertion(SS.getRange().getBegin(), "using "); } diff --git a/test/SemaCXX/deprecated.cpp b/test/SemaCXX/deprecated.cpp index fde2c3754c..74dbf25356 100644 --- a/test/SemaCXX/deprecated.cpp +++ b/test/SemaCXX/deprecated.cpp @@ -26,6 +26,10 @@ void stuff() { struct S { int n; }; struct T : private S { - // FIXME: This is ill-formed in C++11. - S::n; // expected-warning {{access declarations are deprecated; use using declarations instead}} + S::n; +#if __cplusplus < 201103L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif };