diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-06-16 08:51:34 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-06-16 08:51:34 -0400 |
commit | 28462a4496152c76babdb09806762880633191f5 (patch) | |
tree | 290c70325c865fc3ec293cce2b280df32d668aca | |
parent | 668ef28fbb44c1e51d9c5a35b421903c98d87b03 (diff) | |
download | gcc-28462a4496152c76babdb09806762880633191f5.zip gcc-28462a4496152c76babdb09806762880633191f5.tar.gz gcc-28462a4496152c76babdb09806762880633191f5.tar.bz2 |
c++: TI_DEFERRED_ACCESS_CHECKS and dependent decls
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.
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 73f5935..efc69d5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11532,10 +11532,6 @@ perform_instantiation_time_access_checks (tree tmpl, tree targs) 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); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a04b0aa..2e65c27 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -294,6 +294,13 @@ enforce_access (tree basetype_path, tree decl, tree diag_decl, 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; |