pt.c (instantiate_decl): Check typedefs access here.
authorJason Merrill <jason@redhat.com>
Thu, 12 Jul 2012 22:57:16 +0000 (18:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 12 Jul 2012 22:57:16 +0000 (18:57 -0400)
* pt.c (instantiate_decl): Check typedefs access here.
(instantiate_template_1): Not here.

From-SVN: r189444

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

index 299116b81fa289171fb57ec6e76c565e5489825d..c5f23123276fa79fa2dba591895236b64d99ebb1 100644 (file)
@@ -1,5 +1,8 @@
 2012-07-12  Jason Merrill  <jason@redhat.com>
 
+       * pt.c (instantiate_decl): Check typedefs access here.
+       (instantiate_template_1): Not here.
+
        * 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.
index fec88eb4a34942b5bd1293ce477ddb59a5b5071b..95c6464e61b43cbdb3e034f7f3ce440b2014898e 100644 (file)
@@ -8334,7 +8334,7 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags,
 
 /* Perform (or defer) access check for typedefs that were referenced
    from within the template TMPL code.
-   This is a subroutine of instantiate_template and instantiate_class_template.
+   This is a subroutine of instantiate_decl and instantiate_class_template.
    TMPL is the template to consider and TARGS is the list of arguments of
    that template.  */
 
@@ -14380,12 +14380,6 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain)
   /* Now we know the specialization, compute access previously
      deferred.  */
   push_access_scope (fndecl);
-
-  /* Some typedefs referenced from within the template code need to be access
-     checked at template instantiation time, i.e now. These types were
-     added to the template at parsing time. Let's get those and perfom
-     the acces checks then.  */
-  perform_typedefs_access_check (DECL_TEMPLATE_RESULT (tmpl), targ_ptr);
   perform_deferred_access_checks ();
   pop_access_scope (fndecl);
   pop_deferring_access_checks ();
@@ -18395,6 +18389,13 @@ instantiate_decl (tree d, int defer_ok,
       /* Set up context.  */
       start_preparsed_function (d, NULL_TREE, SF_PRE_PARSED);
 
+      /* Some typedefs referenced from within the template code need to be
+        access checked at template instantiation time, i.e now. These
+        types were added to the template at parsing time. Let's get those
+        and perform the access checks then.  */
+      perform_typedefs_access_check (DECL_TEMPLATE_RESULT (gen_tmpl),
+                                    gen_args);
+
       /* Create substitution entries for the parameters.  */
       subst_decl = DECL_TEMPLATE_RESULT (template_for_substitution (d));
       tmpl_parm = DECL_ARGUMENTS (subst_decl);
index 0cacf7494798f466e633b0f1725238dfffb1384c..a32e48aa0499a590422b8d6315a80b402da87653 100644 (file)
@@ -1625,7 +1625,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
 /* If we are currently parsing a template and we encountered a typedef
    TYPEDEF_DECL that is being accessed though CONTEXT, this function
    adds the typedef to a list tied to the current template.
-   At tempate instantiatin time, that list is walked and access check
+   At template instantiation time, that list is walked and access check
    performed for each typedef.
    LOCATION is the location of the usage point of TYPEDEF_DECL.  */
 
index c7c7c989f729330474b0abf0fd0a6eeadad1dfb3..a08d7b3a939f98048735a5710d99b8b907a6932f 100644 (file)
@@ -18,8 +18,8 @@ template <int>
 int
 bar ()
 {
-  Beta<0>::Y i = 0;
-  return Alpha::X ();
+  Beta<0>::Y i = 0;            // { dg-error "within this context" }
+  return Alpha::X ();          // { dg-error "within this context" }
 }
 
-int i = bar<0> (); // { dg-error "within this context" }
+int i = bar<0> ();