]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pt.c (deduction_tsubst_fntype): Just suppress access checking.
authorJason Merrill <jason@redhat.com>
Thu, 12 Jul 2012 22:57:03 +0000 (18:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 12 Jul 2012 22:57:03 +0000 (18:57 -0400)
* pt.c (deduction_tsubst_fntype): Just suppress access checking.
(instantiate_template_1): Set DECL_TI_TEMPLATE before access checking.
(push_deduction_access_scope, pop_deduction_access_scope): Remove.

From-SVN: r189443

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/sfinae6_neg.C

index fd2ba7315cd88a530be52ebf6749d2666a972bef..299116b81fa289171fb57ec6e76c565e5489825d 100644 (file)
@@ -1,3 +1,9 @@
+2012-07-12  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (deduction_tsubst_fntype): Just suppress access checking.
+       (instantiate_template_1): Set DECL_TI_TEMPLATE before access checking.
+       (push_deduction_access_scope, pop_deduction_access_scope): Remove.
+
 2012-07-11  Jason Merrill  <jason@redhat.com>
 
        DR 1402
index 72b0c4f18b219c0f74abc8ca8a1f46e0aca28d75..fec88eb4a34942b5bd1293ce477ddb59a5b5071b 100644 (file)
@@ -116,8 +116,6 @@ enum template_base_result {
 
 static void push_access_scope (tree);
 static void pop_access_scope (tree);
-static void push_deduction_access_scope (tree);
-static void pop_deduction_access_scope (tree);
 static bool resolve_overloaded_unification (tree, tree, tree, tree,
                                            unification_kind_t, int,
                                            bool);
@@ -14263,9 +14261,10 @@ deduction_tsubst_fntype (tree fn, tree targs, tsubst_flags_t complain)
 
   input_location = DECL_SOURCE_LOCATION (fn);
   ++deduction_depth;
-  push_deduction_access_scope (fn);
+  /* We will do access checks in instantiate_template.  */
+  push_deferring_access_checks (dk_deferred);
   r = tsubst (fntype, targs, complain, NULL_TREE);
-  pop_deduction_access_scope (fn);
+  pop_deferring_access_checks ();
   --deduction_depth;
 
   if (excessive_deduction_depth)
@@ -14374,6 +14373,10 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain)
   if (fndecl == error_mark_node)
     return error_mark_node;
 
+  /* The DECL_TI_TEMPLATE should always be the immediate parent
+     template, not the most general template.  */
+  DECL_TI_TEMPLATE (fndecl) = tmpl;
+
   /* Now we know the specialization, compute access previously
      deferred.  */
   push_access_scope (fndecl);
@@ -14387,10 +14390,6 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain)
   pop_access_scope (fndecl);
   pop_deferring_access_checks ();
 
-  /* The DECL_TI_TEMPLATE should always be the immediate parent
-     template, not the most general template.  */
-  DECL_TI_TEMPLATE (fndecl) = tmpl;
-
   /* If we've just instantiated the main entry point for a function,
      instantiate all the alternate entry points as well.  We do this
      by cloning the instantiation of the main entry point, not by
@@ -14413,36 +14412,6 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain)
   return ret;
 }
 
-/* We're going to do deduction substitution on the type of TMPL, a function
-   template.  In C++11 mode, push into that access scope.  In C++03 mode,
-   disable access checking.  */
-
-static void
-push_deduction_access_scope (tree tmpl)
-{
-  if (cxx_dialect >= cxx0x)
-    {
-      int ptd = processing_template_decl;
-      push_access_scope (DECL_TEMPLATE_RESULT (tmpl));
-      /* Preserve processing_template_decl across push_to_top_level.  */
-      if (ptd && !processing_template_decl)
-       ++processing_template_decl;
-    }
-  else
-    push_deferring_access_checks (dk_no_check);
-}
-
-/* And pop back out.  */
-
-static void
-pop_deduction_access_scope (tree tmpl)
-{
-  if (cxx_dialect >= cxx0x)
-    pop_access_scope (DECL_TEMPLATE_RESULT (tmpl));
-  else
-    pop_deferring_access_checks ();
-}
-
 /* PARM is a template parameter pack for FN.  Returns true iff
    PARM is used in a deducible way in the argument list of FN.  */
 
index 8cb337b11af327a5f668d3b48a267b0e1a7a763a..c794248ef27a5b64ad25cabffa7678b3dd489405 100644 (file)
@@ -1,3 +1,7 @@
+2012-07-12  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/template/sfinae6_neg.C: Adjust.
+
 2012-07-12  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.dg/c_f_pointer_shape_tests_5.f90: New.
index 9b7bdfd134d5a47b8e2c9f745248f146f1ac4a09..c238222af75c388d4185bb21724c77cb697a9def 100644 (file)
@@ -14,7 +14,7 @@ template<typename T> struct enable_if<false, T> { };
 template<typename F, typename T1, typename T2>
   typename enable_if<sizeof(create_a<F>()(create_a<T1>(), create_a<T2>()), 1),
                     yes_type>::type
-  check_is_callable2(type<F>, type<T1>, type<T2>); // { dg-error "within this context" "" { target c++11 } }
+  check_is_callable2(type<F>, type<T1>, type<T2>);
 
 no_type check_is_callable2(...);