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.

llvm-svn: 183882
This commit is contained in:
Richard Smith 2013-06-13 02:12:17 +00:00
parent 8ca78a16f4
commit f026b60099
3 changed files with 13 additions and 4 deletions

View File

@ -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<Deprecated>;
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<Deprecated>, DefaultIgnore;

View File

@ -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 ");
}

View File

@ -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
};