aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2011-01-28 23:35:59 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2011-01-29 00:35:59 +0100
commitbc44baadce0f8c990e87b6b8876756f695e28326 (patch)
treef6331eb712bb93cb702bf05a9c41335d882dacb7
parent46adbf0c6b9b8019e1ee4586c8b85096f102e8b3 (diff)
downloadgcc-bc44baadce0f8c990e87b6b8876756f695e28326.zip
gcc-bc44baadce0f8c990e87b6b8876756f695e28326.tar.gz
gcc-bc44baadce0f8c990e87b6b8876756f695e28326.tar.bz2
re PR preprocessor/47311 ([C++0x] ICE in tsubst @cp/pt.c:10502)
Fix PR c++/47311 gcc/cp/ PR c++/47311 * cp-tree.h (fixup_template_parms): Declare. * pt.c (end_template_parm_list): Do not fixup template parms here. (fixup_template_parms): Remove static. Fix typo in the comments. Remove useless code statement. (fixup_template_parm): For a template template parameter, fixup its attributes before fixing up its type. * parser.c (cp_parser_template_declaration_after_export): After parsing template parameters fixup their types. gcc/testsuite/ PR c++/47311 * g++.dg/template/param2.C: New test. From-SVN: r169377
-rw-r--r--gcc/cp/ChangeLog13
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/cp/pt.c36
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/param2.C8
6 files changed, 49 insertions, 21 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4e5c760..b38ed5f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-29 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/47311
+ * cp-tree.h (fixup_template_parms): Declare.
+ * pt.c (end_template_parm_list): Do not fixup template parms here.
+ (fixup_template_parms): Remove static. Fix typo in the
+ comments. Remove useless code statement.
+ (fixup_template_parm): For a template template parameter, fixup
+ its attributes before fixing up its type.
+ * parser.c
+ (cp_parser_template_declaration_after_export): After parsing
+ template parameters fixup their types.
+
2011-01-26 Jakub Jelinek <jakub@redhat.com>
PR c++/47476
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7500826..934dab8 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5025,6 +5025,7 @@ extern bool is_auto (const_tree);
extern tree process_template_parm (tree, location_t, tree,
bool, bool, unsigned);
extern tree end_template_parm_list (tree);
+void fixup_template_parms (void);
extern void end_template_decl (void);
extern tree maybe_update_decl_type (tree, tree);
extern bool check_default_tmpl_args (tree, tree, int, int, int);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 41f82ac..2b6a752 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -19919,8 +19919,11 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
parameter_list = NULL_TREE;
}
else
- /* Parse the template parameters. */
- parameter_list = cp_parser_template_parameter_list (parser);
+ {
+ /* Parse the template parameters. */
+ parameter_list = cp_parser_template_parameter_list (parser);
+ fixup_template_parms ();
+ }
/* Get the deferred access checks from the parameter list. These
will be checked once we know what is being declared, as for a
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7d39e1c..d59f32a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -194,7 +194,6 @@ static tree template_parm_to_arg (tree t);
static tree current_template_args (void);
static tree fixup_template_type_parm_type (tree, int);
static tree fixup_template_parm_index (tree, tree, int);
-static void fixup_template_parms (void);
static tree tsubst_template_parm (tree, tree, tsubst_flags_t);
/* Make the current scope suitable for access checking when we are
@@ -3614,8 +3613,6 @@ end_template_parm_list (tree parms)
TREE_CHAIN (parm) = NULL_TREE;
}
- fixup_template_parms ();
-
--processing_template_parmlist;
return saved_parmlist;
@@ -3774,21 +3771,16 @@ fixup_template_parm (tree parm_desc,
{
/* PARM is a template template parameter. This is going to
be interesting. */
- tree tparms, targs, innermost_args;
+ tree tparms, targs, innermost_args, t;
int j;
- /* First, fix up the type of the parm. */
+ /* First, fix up the parms of the template template parm
+ because the parms are involved in defining the new canonical
+ type of the template template parm. */
- tree t =
- fixup_template_type_parm_type (TREE_TYPE (parm), num_parms);
- TREE_TYPE (parm) = t;
-
- TREE_VEC_ELT (fixedup_args, idx) =
- template_parm_to_arg (parm_desc);
-
- /* Now we need to substitute the template parm types that
- have been fixed up so far into the non-type template
- parms of this template template parm. E.g, consider this:
+ /* So we need to substitute the template parm types that have
+ been fixed up so far into the template parms of this template
+ template parm. E.g, consider this:
template<class T, template<T u> class TT> class S;
@@ -3827,6 +3819,14 @@ fixup_template_parm (tree parm_desc,
TREE_VEC_LENGTH (tparms),
targs);
}
+
+ /* Now fix up the type of the template template parm. */
+
+ t = fixup_template_type_parm_type (TREE_TYPE (parm), num_parms);
+ TREE_TYPE (parm) = t;
+
+ TREE_VEC_ELT (fixedup_args, idx) =
+ template_parm_to_arg (parm_desc);
}
else if (TREE_CODE (parm) == PARM_DECL)
{
@@ -3882,11 +3882,11 @@ fixup_template_parm (tree parm_desc,
pop_deferring_access_checks ();
}
-/* Walk current the template parms and properly compute the canonical
+/* Walk the current template parms and properly compute the canonical
types of the dependent types created during
cp_parser_template_parameter_list. */
-static void
+void
fixup_template_parms (void)
{
tree arglist;
@@ -3911,8 +3911,6 @@ fixup_template_parms (void)
arglist = current_template_args ();
arglist = add_outermost_template_args (arglist, fixedup_args);
- fixedup_args = INNERMOST_TEMPLATE_ARGS (arglist);
-
/* Let's do the proper fixup now. */
for (i = 0; i < num_parms; ++i)
fixup_template_parm (TREE_VEC_ELT (parameter_vec, i),
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 64a7032..f6f203d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-29 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/47311
+ * g++.dg/template/param2.C: New test.
+
2011-01-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/47285
diff --git a/gcc/testsuite/g++.dg/template/param2.C b/gcc/testsuite/g++.dg/template/param2.C
new file mode 100644
index 0000000..d25b855
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/param2.C
@@ -0,0 +1,8 @@
+// Origin PR c++/47311
+// { dg-do compile }
+
+template < typename > class A0;
+template <class Key, class T, template < typename TF = T> class TC = A0> class B0;
+
+template <int> class A1;
+template <class Key, class T, template <T p> class TC = A1> class B1;