From 0857d1f0b1161a03207d64708f083c16880a65f8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 14 Dec 2009 21:11:54 -0500 Subject: [PATCH] re PR c++/42364 (C++ testsuite fails with -g) PR c++/42364 * pt.c (function_parameter_expanded_from_pack_p): Don't require a pack to have a name. (tsubst_decl): Do typedef magic after applying attributes. From-SVN: r155246 --- gcc/cp/ChangeLog | 7 +++++ gcc/cp/pt.c | 40 +++++++++++++------------ gcc/testsuite/ChangeLog | 6 ++++ gcc/testsuite/g++.dg/cpp0x/variadic31.C | 2 +- gcc/testsuite/g++.dg/ext/attrib33.C | 1 + 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bf6ecd8ff4a..fbfed9feb91 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2009-12-14 Jason Merrill + + PR c++/42364 + * pt.c (function_parameter_expanded_from_pack_p): Don't require + a pack to have a name. + (tsubst_decl): Do typedef magic after applying attributes. + 2009-12-15 Paolo Bonzini Shujing Zhao diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 68e277e2cdb..dfd2399bfc5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2730,15 +2730,13 @@ get_function_template_decl (const_tree primary_func_tmpl_inst) bool function_parameter_expanded_from_pack_p (tree param_decl, tree pack) { - if (DECL_ARTIFICIAL (param_decl) - || !function_parameter_pack_p (pack)) - return false; + if (DECL_ARTIFICIAL (param_decl) + || !function_parameter_pack_p (pack)) + return false; - gcc_assert (DECL_NAME (param_decl) && DECL_NAME (pack)); - - /* The parameter pack and its pack arguments have the same - DECL_PARM_INDEX. */ - return DECL_PARM_INDEX (pack) == DECL_PARM_INDEX (param_decl); + /* The parameter pack and its pack arguments have the same + DECL_PARM_INDEX. */ + return DECL_PARM_INDEX (pack) == DECL_PARM_INDEX (param_decl); } /* Determine whether ARGS describes a variadic template args list, @@ -9273,7 +9271,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* Create a new node for the specialization we need. */ r = copy_decl (t); if (type == NULL_TREE) - type = tsubst (TREE_TYPE (t), args, complain, in_decl); + { + if (is_typedef_decl (t)) + type = DECL_ORIGINAL_TYPE (t); + else + type = TREE_TYPE (t); + type = tsubst (type, args, complain, in_decl); + } if (TREE_CODE (r) == VAR_DECL) { /* Even if the original location is out of scope, the @@ -9344,16 +9348,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) } determine_visibility (r); } - /* Preserve a typedef that names a type. */ - else if (TREE_CODE (r) == TYPE_DECL - && DECL_ORIGINAL_TYPE (t) - && type != error_mark_node) - { - DECL_ORIGINAL_TYPE (r) = tsubst (DECL_ORIGINAL_TYPE (t), - args, complain, in_decl); - TREE_TYPE (r) = type = build_variant_type_copy (type); - TYPE_NAME (type) = r; - } if (!local_p) { @@ -9391,6 +9385,14 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) apply_late_template_attributes (&r, DECL_ATTRIBUTES (r), (int) ATTR_FLAG_TYPE_IN_PLACE, args, complain, in_decl); + + /* Preserve a typedef that names a type. */ + if (is_typedef_decl (r)) + { + DECL_ORIGINAL_TYPE (r) = NULL_TREE; + set_underlying_type (r); + } + layout_decl (r, 0); } break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 29f02c097c9..654cb1c32cc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-12-14 Jason Merrill + + PR c++/42364 + * g++.dg/cpp0x/variadic31.C: Compile with -g. + * g++.dg/ext/attrib33.C: Likewise. + 2009-12-15 Shujing Zhao * g++.dg/other/error20.C: Adjust dg-message strings. diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic31.C b/gcc/testsuite/g++.dg/cpp0x/variadic31.C index eacf568978a..db8daa89858 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic31.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic31.C @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -g" } template void eat(T...) { } diff --git a/gcc/testsuite/g++.dg/ext/attrib33.C b/gcc/testsuite/g++.dg/ext/attrib33.C index 5b989849128..55bfc4cadb8 100644 --- a/gcc/testsuite/g++.dg/ext/attrib33.C +++ b/gcc/testsuite/g++.dg/ext/attrib33.C @@ -1,5 +1,6 @@ // PR c++/35546 // { dg-do compile } +// { dg-options "-g" } template struct T