diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-23 16:59:54 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-01-24 17:22:56 -0500 |
commit | 55dd44535d2e4e5703c0103c26e7c51ab8c502c4 (patch) | |
tree | e1545d5470cb4f2f288bdc4f21b857b480a4c95a /gcc/cp | |
parent | 5d782a8d909c5cc472c911c0ab4de0b890aad868 (diff) | |
download | gcc-55dd44535d2e4e5703c0103c26e7c51ab8c502c4.zip gcc-55dd44535d2e4e5703c0103c26e7c51ab8c502c4.tar.gz gcc-55dd44535d2e4e5703c0103c26e7c51ab8c502c4.tar.bz2 |
c++: Fix parameter map handling of member typedef.
any_template_parm_r was looking at the args of an alias template-id, but we
need to look at all args of a member alias/typedef, including implicit ones
from the enclosing class.
PR c++/93377 - ICE with member alias in constraint.
* pt.c (any_template_parm_r): Look at template arguments for all
aliases, not only alias templates.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 20 |
2 files changed, 15 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0ed260b..cddf169 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-24 Jason Merrill <jason@redhat.com> + + PR c++/93377 - ICE with member alias in constraint. + * pt.c (any_template_parm_r): Look at template arguments for all + aliases, not only alias templates. + 2020-01-24 Marek Polacek <polacek@redhat.com> PR c++/93299 - ICE in tsubst_copy with parenthesized expression. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9571992..2090441 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10427,19 +10427,15 @@ any_template_parm_r (tree t, void *data) } \ while (0) + /* A mention of a member alias/typedef is a use of all of its template + arguments, including those from the enclosing class, so we don't use + alias_template_specialization_p here. */ + if (TYPE_P (t) && typedef_variant_p (t)) + if (tree tinfo = TYPE_ALIAS_TEMPLATE_INFO (t)) + WALK_SUBTREE (TI_ARGS (tinfo)); + switch (TREE_CODE (t)) { - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - /* Search for template parameters in type aliases. */ - if (tree ats = alias_template_specialization_p (t, nt_opaque)) - { - tree tinfo = TYPE_ALIAS_TEMPLATE_INFO (ats); - WALK_SUBTREE (TI_ARGS (tinfo)); - } - break; - case TEMPLATE_TYPE_PARM: /* Type constraints of a placeholder type may contain parameters. */ if (is_auto (t)) @@ -10472,6 +10468,8 @@ any_template_parm_r (tree t, void *data) tree cparms = ftpi->ctx_parms; while (TMPL_PARMS_DEPTH (dparms) > ftpi->max_depth) dparms = TREE_CHAIN (dparms); + while (TMPL_PARMS_DEPTH (cparms) > TMPL_PARMS_DEPTH (dparms)) + cparms = TREE_CHAIN (cparms); while (dparms && (TREE_TYPE (TREE_VALUE (dparms)) != TREE_TYPE (TREE_VALUE (cparms)))) |