r183882 - In C++11, promote access declaration diagnostic from warning to error. There
Richard Smith
richard-llvm at metafoo.co.uk
Wed Jun 12 19:12:17 PDT 2013
Author: rsmith
Date: Wed Jun 12 21:12:17 2013
New Revision: 183882
URL: http://llvm.org/viewvc/llvm-project?rev=183882&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/deprecated.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=183882&r1=183881&r2=183882&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 12 21:12:17 2013
@@ -287,6 +287,9 @@ def note_using_decl : Note<"%select{|pre
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;
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=183882&r1=183881&r2=183882&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jun 12 21:12:17 2013
@@ -6742,8 +6742,10 @@ Decl *Sema::ActOnUsingDeclaration(Scope
// 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 ");
}
Modified: cfe/trunk/test/SemaCXX/deprecated.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deprecated.cpp?rev=183882&r1=183881&r2=183882&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/deprecated.cpp Wed Jun 12 21:12:17 2013
@@ -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 at -2 {{access declarations are deprecated; use using declarations instead}}
+#else
+ // expected-error at -4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
};
More information about the cfe-commits
mailing list