diff mbox

[C++] PR 17314

Message ID 5195043B.3090200@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 16, 2013, 4:07 p.m. UTC
Hi,

as agreed, I regtested on x86_64-linux the below diagnostic tweak.

Thanks,
Paolo.

//////////////////////////
/cp
2013-05-16  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/17314
	* call.c (enforce_access): Improve protected access error message.

/testsuite
2013-05-16  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/17314
	* g++.dg/inherit/access9.C: New.
diff mbox

Patch

Index: cp/call.c
===================================================================
--- cp/call.c	(revision 198962)
+++ cp/call.c	(working copy)
@@ -5707,7 +5707,7 @@  enforce_access (tree basetype_path, tree decl, tre
 	  if (TREE_PRIVATE (decl))
 	    error ("%q+#D is private", diag_decl);
 	  else if (TREE_PROTECTED (decl))
-	    error ("%q+#D is protected", diag_decl);
+	    error ("%q+#D, declared protected, is inaccessible", diag_decl);
 	  else
 	    error ("%q+#D is inaccessible", diag_decl);
 	  error ("within this context");
Index: testsuite/g++.dg/inherit/access9.C
===================================================================
--- testsuite/g++.dg/inherit/access9.C	(revision 0)
+++ testsuite/g++.dg/inherit/access9.C	(working copy)
@@ -0,0 +1,16 @@ 
+// PR c++/17314
+
+class A
+{
+protected:
+  A(){}                 // { dg-error "declared protected" }
+};
+
+class B : virtual A {};
+
+class C : public B {};  // { dg-error "within this context" }
+                        // { dg-message "deleted" "" { target c++11 } 11 }
+int main ()
+{
+  C c;                  // { dg-message "required here" "" { target c++98 } }
+}                       // { dg-error "deleted" "" { target c++11 } 15 }