]> granicus.if.org Git - clang/commitdiff
In C++11, promote access declaration diagnostic from warning to error. There
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Jun 2013 02:12:17 +0000 (02:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Jun 2013 02:12:17 +0000 (02:12 +0000)
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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/deprecated.cpp

index 1c9d2955ec44d8bab49a0d87cb7f6f68165bac75..f296c5268ad8b1ccbc6b666f8e2f0b2e03bef2c9 100644 (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;
index be198ad3782cac04a96c7ba51b3ad1fd75528737..a4549fb89296c0dd7173f462589de04a950ca103 100644 (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 ");
   }
 
index fde2c3754c690484fbdbc4ee245a5d73755be6e2..74dbf25356487a4752eec519b9f2cd0053783b2c 100644 (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
 };