diff options
author | Dodji Seketeli <dodji@redhat.com> | 2011-12-09 18:12:45 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2011-12-09 19:12:45 +0100 |
commit | 60ef5d4e7fcf2789986bcf24e2db82dc0ef79bab (patch) | |
tree | c93242d247ad65c273360bbd6a3e8c3ee1cac04e /gcc | |
parent | 15ce64af29141facd203687d000e21fe6f877234 (diff) | |
download | gcc-60ef5d4e7fcf2789986bcf24e2db82dc0ef79bab.zip gcc-60ef5d4e7fcf2789986bcf24e2db82dc0ef79bab.tar.gz gcc-60ef5d4e7fcf2789986bcf24e2db82dc0ef79bab.tar.bz2 |
PR c++/51289 - ICE with alias template for bound template template parm
gcc/cp/
PR c++/51289
* cp-tree.h (TYPE_TEMPLATE_INFO): Rewrite this accessor macro to
better support aliased types.
(TYPE_ALIAS_P): Don't crash on TYPE_NAME nodes that are not
TYPE_DECL.
* pt.c (find_parameter_packs_r): Handle types aliases.
(push_template_decl_real): Check for bare parameter packs in the
underlying type of an alias template.
gcc/PR51289/gcc/testsuite/
PR c++/51289
* g++.dg/cpp0x/alias-decl-17.C: New test.
From-SVN: r182170
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 28 | ||||
-rw-r--r-- | gcc/cp/pt.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/alias-decl-17.C | 21 |
5 files changed, 73 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 14e65c0..3698349 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2011-12-09 Dodji Seketeli <dodji@redhat.com> + + PR c++/51289 + * cp-tree.h (TYPE_TEMPLATE_INFO): Rewrite this accessor macro to + better support aliased types. + (TYPE_ALIAS_P): Don't crash on TYPE_NAME nodes that are not + TYPE_DECL. + * pt.c (find_parameter_packs_r): Handle types aliases. + (push_template_decl_real): Check for bare parameter packs in the + underlying type of an alias template. + 2011-12-08 Jason Merrill <jason@redhat.com> PR c++/51318 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 87cb8b6..955d0eb 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2555,6 +2555,7 @@ extern void decl_shadowed_for_var_insert (tree, tree); #define TYPE_ALIAS_P(NODE) \ (TYPE_P (NODE) \ && TYPE_NAME (NODE) \ + && TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL \ && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE))) /* For a class type: if this structure has many fields, we'll sort them @@ -2607,17 +2608,24 @@ extern void decl_shadowed_for_var_insert (tree, tree); (LANG_TYPE_CLASS_CHECK (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK (NODE)) \ ->template_info) -/* Template information for an ENUMERAL_, RECORD_, or UNION_TYPE. */ +/* Template information for an ENUMERAL_, RECORD_, UNION_TYPE, or + BOUND_TEMPLATE_TEMPLATE_PARM type. Note that if NODE is a + specialization of an alias template, this accessor returns the + template info for the alias template, not the one (if any) for the + template of the underlying type. */ #define TYPE_TEMPLATE_INFO(NODE) \ - (TREE_CODE (NODE) == ENUMERAL_TYPE \ - ? ENUM_TEMPLATE_INFO (NODE) : \ - (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \ - ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) : \ - ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \ - ? CLASSTYPE_TEMPLATE_INFO (NODE) \ - : ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \ - ? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE))) \ - : NULL_TREE)))) + (TYPE_ALIAS_P (NODE) \ + ? ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \ + ? DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) \ + : NULL_TREE) \ + : ((TREE_CODE (NODE) == ENUMERAL_TYPE) \ + ? ENUM_TEMPLATE_INFO (NODE) \ + : ((TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM) \ + ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) \ + : (CLASS_TYPE_P (NODE) \ + ? CLASSTYPE_TEMPLATE_INFO (NODE) \ + : NULL_TREE)))) + /* Set the template information for an ENUMERAL_, RECORD_, or UNION_TYPE to VAL. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 296cd54..bb5aa0c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2976,6 +2976,20 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) (struct find_parameter_pack_data*)data; bool parameter_pack_p = false; + /* Handle type aliases/typedefs. */ + if (TYPE_P (t) + && TYPE_NAME (t) + && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL + && TYPE_DECL_ALIAS_P (TYPE_NAME (t))) + { + if (TYPE_TEMPLATE_INFO (t)) + cp_walk_tree (&TYPE_TI_ARGS (t), + &find_parameter_packs_r, + ppd, ppd->visited); + *walk_subtrees = 0; + return NULL_TREE; + } + /* Identify whether this is a parameter pack or not. */ switch (TREE_CODE (t)) { @@ -4905,7 +4919,10 @@ push_template_decl_real (tree decl, bool is_friend) if (check_for_bare_parameter_packs (TYPE_RAISES_EXCEPTIONS (type))) TYPE_RAISES_EXCEPTIONS (type) = NULL_TREE; } - else if (check_for_bare_parameter_packs (TREE_TYPE (decl))) + else if (check_for_bare_parameter_packs ((TREE_CODE (decl) == TYPE_DECL + && TYPE_DECL_ALIAS_P (decl)) + ? DECL_ORIGINAL_TYPE (decl) + : TREE_TYPE (decl))) { TREE_TYPE (decl) = error_mark_node; return error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a97bf7..2430c7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-09 Dodji Seketeli <dodji@redhat.com> + + PR c++/51289 + * g++.dg/cpp0x/alias-decl-17.C: New test. + 2011-12-09 Michael Meissner <meissner@the-meissners.org> * gcc.target/powerpc/recip-5.c: Disable running on any system that diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-17.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-17.C new file mode 100644 index 0000000..41b1c95 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-17.C @@ -0,0 +1,21 @@ +// Origin PR c++/51289 +// { dg-options "-std=c++11" } + +template<typename a, template <typename, typename> class b> +struct foo { + template <typename t> + using type = b<a, t>; + template <typename t> + b<a, t> funca() {} + + template <typename t> + type<t> funcb() {} +}; + +// This is an additional test, to emit an error message when using +// unexpanded parameter packs in an alias declaration. +template <class ... T> +struct S {}; + +template<class ... T> +using A = S<T>; // { dg-error "parameter packs not expanded" } |