diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-04-28 21:45:59 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-04-28 21:45:59 -0400 |
commit | 1d2290caad0dba52b285b47057b7c0e4e8d21feb (patch) | |
tree | 94a47e7247bd4d63ced7a4039867470b5c83b0ba /gcc/cp | |
parent | 43439d5e8424f3a746003ef8953e1cdc120fbbd7 (diff) | |
download | gcc-1d2290caad0dba52b285b47057b7c0e4e8d21feb.zip gcc-1d2290caad0dba52b285b47057b7c0e4e8d21feb.tar.gz gcc-1d2290caad0dba52b285b47057b7c0e4e8d21feb.tar.bz2 |
c++: Satisfaction caching of inherited ctor [PR94819]
As observed in PR94719, an inherited constructor for an instantiation of
a constructor template confusingly has as its DECL_INHERITED_CTOR the
TEMPLATE_DECL of the constructor template rather than the particular
instantiation of the template.
This means two inherited constructors for two different instantiations
of the same constructor template have the same DECL_INHERITED_CTOR. And
since in satisfy_declaration_constraints our decl satisfaction cache is
keyed off of the result of strip_inheriting_ctors, we may end up
conflating the satisfaction values of the two inherited constructors'
constraints.
This patch fixes this issue by using the original tree, not the result
of strip_inheriting_ctors, as the key to the decl satisfaction cache.
gcc/cp/ChangeLog:
PR c++/94819
* constraint.cc (satisfy_declaration_constraints): Use saved_t
instead of t as the key to decl_satisfied_cache.
gcc/testsuite/ChangeLog:
PR c++/94819
* g++.dg/cpp2a/concepts-inherit-ctor10.C: New test.
* g++.dg/cpp2a/concepts-inherit-ctor11.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/constraint.cc | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c055801..f2bfe84 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2020-04-29 Patrick Palka <ppalka@redhat.com> + PR c++/94819 + * constraint.cc (satisfy_declaration_constraints): Use saved_t + instead of t as the key to decl_satisfied_cache. + PR c++/94808 * error.c (print_requires_expression_info): Print the dependent form of the parameter list with its template parameter mapping, diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 06161b8..866b0f5 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2752,7 +2752,7 @@ satisfy_declaration_constraints (tree t, subst_info info) info.in_decl = t; if (info.quiet ()) - if (tree *result = hash_map_safe_get (decl_satisfied_cache, t)) + if (tree *result = hash_map_safe_get (decl_satisfied_cache, saved_t)) return *result; /* Get the normalized constraints. */ @@ -2787,7 +2787,7 @@ satisfy_declaration_constraints (tree t, subst_info info) } if (info.quiet ()) - hash_map_safe_put<hm_ggc> (decl_satisfied_cache, t, result); + hash_map_safe_put<hm_ggc> (decl_satisfied_cache, saved_t, result); return result; } |