re PR c++/49042 ([C++0x] wrong "protected" when using template and decltype)
authorJason Merrill <jason@redhat.com>
Tue, 24 May 2011 23:44:59 +0000 (19:44 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 24 May 2011 23:44:59 +0000 (19:44 -0400)
PR c++/49042
* pt.c (get_mostly_instantiated_function_type): Use
push_deferring_access_checks rather than set flag_access_control.

From-SVN: r174151

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/access01.C [new file with mode: 0644]

index 6397194d7381d6483cee3e356c78f228312d368f..d9d8a549e62fdb4478a290e6b39ec6a0e3d181a6 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-24  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49042
+       * pt.c (get_mostly_instantiated_function_type): Use
+       push_deferring_access_checks rather than set flag_access_control.
+
 2011-05-24  Nicola Pero  <nicola.pero@meta-innovation.com>,
 
        * parser.c (cp_parser_objc_class_ivars): Deal gracefully with a
index 98844c37017ccd1bfb1683a2b8df9ce674feb457..bd9aeba91b8fec234e6bc67253ff1601ccede5da 100644 (file)
@@ -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;
index c1dcaedaf6569bfab8e817c69bd3d1d1690c2d71..14ef5becfa7b85562a4d08c75b43138a28a41084 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-24  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/access01.C: New.
+
 2011-05-24  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        PR libobjc/48177
diff --git a/gcc/testsuite/g++.dg/cpp0x/access01.C b/gcc/testsuite/g++.dg/cpp0x/access01.C
new file mode 100644 (file)
index 0000000..43e5e86
--- /dev/null
@@ -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>();
+}