diff options
author | Douglas Gregor <doug.gregor@gmail.com> | 2008-02-15 17:33:02 +0000 |
---|---|---|
committer | Doug Gregor <dgregor@gcc.gnu.org> | 2008-02-15 17:33:02 +0000 |
commit | 92fab505d29cc38f12ad0369648ef7d0a54a3aef (patch) | |
tree | 4be6e73c708aaa2c7d6a020cbfcf01b14cf713f1 /gcc/cp | |
parent | e8900287b29f4a9093299f76ab8838f79ea151c6 (diff) | |
download | gcc-92fab505d29cc38f12ad0369648ef7d0a54a3aef.zip gcc-92fab505d29cc38f12ad0369648ef7d0a54a3aef.tar.gz gcc-92fab505d29cc38f12ad0369648ef7d0a54a3aef.tar.bz2 |
re PR c++/35023 (ICE with parameter pack in variable declaration)
2008-02-15 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35023
PR c++/35024
PR c++/35026
* pt.c (finish_member_template_decl): If the type in a TYPE_DECL
is error_mark_node, return an error early.
(find_parameter_packs_r): Pass the pointer set along to recursive
calls of cp_walk_subtrees; don't try to manage the pointer set
ourselves.
(uses_parameter_packs): Pass the pointer set to cp_walk_tree.
(make_pack_expansion): Ditto.
(check_for_bare_parameter_packs): Ditto. Also, don't bother taking
a second pass through the tree with find_parameter_packs_r; that
second pass no longer does anything.
(push_template_decl_real): If we have an erroneous declaration,
set its type to error_mark_node before returning an error.
2008-02-15 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35023
PR c++/35024
PR c++/35026
* g++.dg/cpp0x/vt-35026.C: New.
* g++.dg/cpp0x/vt-35023.C: New.
* g++.dg/cpp0x/vt-34055.C: Tweak expected error messages.
* g++.dg/cpp0x/vt-35024.C: New.
From-SVN: r132348
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/cp/pt.c | 51 |
2 files changed, 38 insertions, 31 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3853983..6789236 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,21 @@ +2008-02-15 Douglas Gregor <doug.gregor@gmail.com> + + PR c++/35023 + PR c++/35024 + PR c++/35026 + * pt.c (finish_member_template_decl): If the type in a TYPE_DECL + is error_mark_node, return an error early. + (find_parameter_packs_r): Pass the pointer set along to recursive + calls of cp_walk_subtrees; don't try to manage the pointer set + ourselves. + (uses_parameter_packs): Pass the pointer set to cp_walk_tree. + (make_pack_expansion): Ditto. + (check_for_bare_parameter_packs): Ditto. Also, don't bother taking + a second pass through the tree with find_parameter_packs_r; that + second pass no longer does anything. + (push_template_decl_real): If we have an erroneous declaration, + set its type to error_mark_node before returning an error. + 2008-02-14 Douglas Gregor <doug.gregor@gmail.com> PR c++/34050 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d11a959..5931126 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -236,6 +236,8 @@ finish_member_template_decl (tree decl) tree type; type = TREE_TYPE (decl); + if (type == error_mark_node) + return error_mark_node; if (IS_AGGR_TYPE (type) && CLASSTYPE_TEMPLATE_INFO (type) && !CLASSTYPE_TEMPLATE_SPECIALIZATION (type)) @@ -2445,13 +2447,6 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) (struct find_parameter_pack_data*)data; bool parameter_pack_p = false; - /* Don't visit nodes twice. */ - if (pointer_set_contains (ppd->visited, *tp)) - { - *walk_subtrees = 0; - return NULL_TREE; - } - /* Identify whether this is a parameter pack or not. */ switch (TREE_CODE (t)) { @@ -2487,12 +2482,9 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) *ppd->parameter_packs = tree_cons (NULL_TREE, t, *ppd->parameter_packs); } - /* Make sure we do not visit this node again. */ - pointer_set_insert (ppd->visited, *tp); - if (TYPE_P (t)) cp_walk_tree (&TYPE_CONTEXT (t), - &find_parameter_packs_r, ppd, NULL); + &find_parameter_packs_r, ppd, ppd->visited); /* This switch statement will return immediately if we don't find a parameter pack. */ @@ -2504,10 +2496,10 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) case BOUND_TEMPLATE_TEMPLATE_PARM: /* Check the template itself. */ cp_walk_tree (&TREE_TYPE (TYPE_TI_TEMPLATE (t)), - &find_parameter_packs_r, ppd, NULL); + &find_parameter_packs_r, ppd, ppd->visited); /* Check the template arguments. */ cp_walk_tree (&TYPE_TI_ARGS (t), &find_parameter_packs_r, ppd, - NULL); + ppd->visited); *walk_subtrees = 0; return NULL_TREE; @@ -2527,19 +2519,19 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) case ENUMERAL_TYPE: if (TYPE_TEMPLATE_INFO (t)) cp_walk_tree (&TREE_VALUE (TYPE_TEMPLATE_INFO (t)), - &find_parameter_packs_r, ppd, NULL); + &find_parameter_packs_r, ppd, ppd->visited); *walk_subtrees = 0; return NULL_TREE; case TEMPLATE_DECL: cp_walk_tree (&TREE_TYPE (t), - &find_parameter_packs_r, ppd, NULL); + &find_parameter_packs_r, ppd, ppd->visited); return NULL_TREE; case TYPENAME_TYPE: cp_walk_tree (&TYPENAME_TYPE_FULLNAME (t), &find_parameter_packs_r, - ppd, NULL); + ppd, ppd->visited); *walk_subtrees = 0; return NULL_TREE; @@ -2550,12 +2542,13 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) case INTEGER_TYPE: cp_walk_tree (&TYPE_MAX_VALUE (t), &find_parameter_packs_r, - ppd, NULL); + ppd, ppd->visited); *walk_subtrees = 0; return NULL_TREE; case IDENTIFIER_NODE: - cp_walk_tree (&TREE_TYPE (t), &find_parameter_packs_r, ppd, NULL); + cp_walk_tree (&TREE_TYPE (t), &find_parameter_packs_r, ppd, + ppd->visited); *walk_subtrees = 0; return NULL_TREE; @@ -2574,7 +2567,7 @@ uses_parameter_packs (tree t) struct find_parameter_pack_data ppd; ppd.parameter_packs = ¶meter_packs; ppd.visited = pointer_set_create (); - cp_walk_tree (&t, &find_parameter_packs_r, &ppd, NULL); + cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited); pointer_set_destroy (ppd.visited); return parameter_packs != NULL_TREE; } @@ -2625,7 +2618,7 @@ make_pack_expansion (tree arg) ppd.visited = pointer_set_create (); ppd.parameter_packs = ¶meter_packs; cp_walk_tree (&TREE_PURPOSE (arg), &find_parameter_packs_r, - &ppd, NULL); + &ppd, ppd.visited); if (parameter_packs == NULL_TREE) { @@ -2643,7 +2636,7 @@ make_pack_expansion (tree arg) /* Determine which parameter packs will be expanded in this argument. */ cp_walk_tree (&TREE_VALUE (value), &find_parameter_packs_r, - &ppd, NULL); + &ppd, ppd.visited); } } @@ -2681,7 +2674,7 @@ make_pack_expansion (tree arg) /* Determine which parameter packs will be expanded. */ ppd.parameter_packs = ¶meter_packs; ppd.visited = pointer_set_create (); - cp_walk_tree (&arg, &find_parameter_packs_r, &ppd, NULL); + cp_walk_tree (&arg, &find_parameter_packs_r, &ppd, ppd.visited); pointer_set_destroy (ppd.visited); /* Make sure we found some parameter packs. */ @@ -2726,7 +2719,7 @@ check_for_bare_parameter_packs (tree t) ppd.parameter_packs = ¶meter_packs; ppd.visited = pointer_set_create (); - cp_walk_tree (&t, &find_parameter_packs_r, &ppd, NULL); + cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited); pointer_set_destroy (ppd.visited); if (parameter_packs) @@ -2753,13 +2746,6 @@ check_for_bare_parameter_packs (tree t) parameter_packs = TREE_CHAIN (parameter_packs); } - /* Clean up any references to these parameter packs within the - tree. */ - ppd.parameter_packs = ¶meter_packs; - ppd.visited = pointer_set_create (); - cp_walk_tree (&t, &find_parameter_packs_r, &ppd, NULL); - pointer_set_destroy (ppd.visited); - return true; } @@ -3887,7 +3873,10 @@ push_template_decl_real (tree decl, bool is_friend) TYPE_RAISES_EXCEPTIONS (type) = NULL_TREE; } else if (check_for_bare_parameter_packs (TREE_TYPE (decl))) - return error_mark_node; + { + TREE_TYPE (decl) = error_mark_node; + return error_mark_node; + } if (is_partial) return process_partial_specialization (decl); |