This adds an assert to enforce_access to verify that we don't defer
access checks of dependent decls -- we should instead be rechecking the
access of such a decl after tsubst'ing into the user of the decl.
gcc/cp/ChangeLog:
* pt.c (perform_instantiation_time_access_checks): No need to
tsubst into decl.
* semantics.c (enforce_access): Verify that decl is not
dependent.
tree diag_decl = chk->diag_decl;
tree type_scope = TREE_TYPE (chk->binfo);
- if (uses_template_parms (decl)
- || (TREE_CODE (decl) == FIELD_DECL
- && uses_template_parms (DECL_CONTEXT (decl))))
- decl = tsubst_copy (decl, targs, tf_error, NULL_TREE);
if (uses_template_parms (type_scope))
type_scope = tsubst (type_scope, targs, tf_error, NULL_TREE);
assume it'll be accessible at instantiation time. */
return true;
+ /* Access of a dependent decl should be rechecked after tsubst'ing
+ into the user of the decl, rather than explicitly deferring the
+ check here. */
+ gcc_assert (!uses_template_parms (decl));
+ if (TREE_CODE (decl) == FIELD_DECL)
+ gcc_assert (!uses_template_parms (DECL_CONTEXT (decl)));
+
/* Defer this access check until instantiation time. */
deferred_access_check access_check;
access_check.binfo = basetype_path;