aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-10-05 09:50:02 -0400
committerPatrick Palka <ppalka@redhat.com>2021-10-05 09:50:02 -0400
commitf3930418cb82000fae3cb4e98e870428800cf295 (patch)
tree5609e92195272b7a11bf3bb262eba6298b5f024c /gcc/cp
parent7f4192dd3d84cb3f6584ae847eae18519d1eb76d (diff)
downloadgcc-f3930418cb82000fae3cb4e98e870428800cf295.zip
gcc-f3930418cb82000fae3cb4e98e870428800cf295.tar.gz
gcc-f3930418cb82000fae3cb4e98e870428800cf295.tar.bz2
c++: templated static local var has value-dep addr [PR98930]
Here uses_template_parms returns false for the dependent type A<&impl::i>, which causes tsubst_aggr_type to think it's non-dependent and not bother substituting into it, leading to breakage. This patch fixes this by making has_value_dependent_address also return true for templated static local variables. PR c++/98930 gcc/cp/ChangeLog: * pt.c (has_value_dependent_address): Return true for a static local variable from a function template. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/nontype4.C: New test. * g++.dg/cpp1z/nontype4a.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1dcdffe..844b7c1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6760,8 +6760,15 @@ has_value_dependent_address (tree op)
if (DECL_P (op))
{
tree ctx = CP_DECL_CONTEXT (op);
+
if (TYPE_P (ctx) && dependent_type_p (ctx))
return true;
+
+ if (VAR_P (op)
+ && TREE_STATIC (op)
+ && TREE_CODE (ctx) == FUNCTION_DECL
+ && type_dependent_expression_p (ctx))
+ return true;
}
return false;