diff mbox

C++ PATCH for c++/45917 (missing access error with template-id nested-name-specifier)

Message ID 514521CA.3000207@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 17, 2013, 1:52 a.m. UTC
We were saving up the access check perfectly well, but then 
inadvertently throwing it away because of a call to 
pop_deferring_access_checks (which discards them) rather than 
pop_to_parent_deferring_access_checks (which adds them to the parent 
context).

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 93fa63b45d657409ab35823b824f3acaa3e8b1ae
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 14 17:14:07 2013 -0400

    	PR c++/45917
    	* parser.c (cp_parser_template_id): Don't forget access checks.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b0df636..f4a4278 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12818,7 +12818,7 @@  cp_parser_template_id (cp_parser *parser,
 	error_at (token->location, "parse error in template argument list");
     }
 
-  pop_deferring_access_checks ();
+  pop_to_parent_deferring_access_checks ();
   return template_id;
 }
 
diff --git a/gcc/testsuite/g++.dg/template/access26.C b/gcc/testsuite/g++.dg/template/access26.C
new file mode 100644
index 0000000..1c5de9a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/access26.C
@@ -0,0 +1,6 @@ 
+// PR c++/45917
+
+template < typename T >
+struct A { static int i; };
+class B { typedef int X; };	// { dg-error "private" }
+void f() { A<B::X>::i = 0; }	// { dg-error "this context" }