Patchwork C++ PATCH for c++/49042 (another acccess/templates issue)

login
register
mail settings
Submitter Jason Merrill
Date May 24, 2011, 11:44 p.m.
Message ID <4DDC42CE.5000109@redhat.com>
Download mbox | patch
Permalink /patch/97245/
State New
Headers show

Comments

Jason Merrill - May 24, 2011, 11:44 p.m.
...except we hit this one in mangling rather than deduction.  There was 
already code here to suppress access control here, but it doesn't work 
anymore, since flag_access_control is now only checked at the beginning 
of compilation.  The fix is to use push_deferring_access_checks instead.

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

Patch

commit b59f44587a32d3ff68d0dedac8f82df1f299cfd0
Author: Jason Merrill <jason@redhat.com>
Date:   Tue May 24 16:48:02 2011 -0400

    	PR c++/49042
    	* pt.c (get_mostly_instantiated_function_type): Use
    	push_deferring_access_checks rather than set flag_access_control.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 98844c3..bd9aeba 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18045,7 +18045,7 @@  get_mostly_instantiated_function_type (tree decl)
     ;
   else
     {
-      int i, save_access_control;
+      int i;
       tree partial_args;
 
       /* Replace the innermost level of the TARGS with NULL_TREEs to
@@ -18060,8 +18060,7 @@  get_mostly_instantiated_function_type (tree decl)
 
       /* Disable access control as this function is used only during
 	 name-mangling.  */
-      save_access_control = flag_access_control;
-      flag_access_control = 0;
+      push_deferring_access_checks (dk_no_check);
 
       ++processing_template_decl;
       /* Now, do the (partial) substitution to figure out the
@@ -18076,7 +18075,7 @@  get_mostly_instantiated_function_type (tree decl)
       TREE_VEC_LENGTH (partial_args)--;
       tparms = tsubst_template_parms (tparms, partial_args, tf_error);
 
-      flag_access_control = save_access_control;
+      pop_deferring_access_checks ();
     }
 
   return fn_type;
diff --git a/gcc/testsuite/g++.dg/cpp0x/access01.C b/gcc/testsuite/g++.dg/cpp0x/access01.C
new file mode 100644
index 0000000..43e5e86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/access01.C
@@ -0,0 +1,15 @@ 
+// PR c++/49042
+// { dg-options -std=c++0x }
+
+template <class T>
+class A
+{
+  T p;
+public:
+  template <class U> auto f() -> decltype(+p) { }
+};
+
+int main()
+{
+  A<int>().f<int>();
+}