diff options
author | Jason Merrill <jason@redhat.com> | 2009-12-28 22:33:24 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-12-28 22:33:24 -0500 |
commit | 4db98b6eb5a8a9994b8d24ce68521f4930212fdf (patch) | |
tree | 1b1de75785ef94b8ed3972f4ea28c7f486132b62 | |
parent | 2838468cc33125cf9948190cf2b8509ac9b0cd9c (diff) | |
download | gcc-4db98b6eb5a8a9994b8d24ce68521f4930212fdf.zip gcc-4db98b6eb5a8a9994b8d24ce68521f4930212fdf.tar.gz gcc-4db98b6eb5a8a9994b8d24ce68521f4930212fdf.tar.bz2 |
re PR c++/42447 (ICE during processing complex templates)
PR c++/42447
* pt.c (iterative_hash_template_arg): Don't rely on TYPE_CANONICAL
for ARRAY_TYPE.
From-SVN: r155499
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/array21.C | 50 |
4 files changed, 68 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 57a4643..c39304c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-12-28 Jason Merrill <jason@redhat.com> + + PR c++/42447 + * pt.c (iterative_hash_template_arg): Don't rely on TYPE_CANONICAL + for ARRAY_TYPE. + 2009-12-24 Jason Merrill <jason@redhat.com> PR c++/41305, DR 384 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 85ad539..d5342a1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1553,6 +1553,13 @@ iterative_hash_template_arg (tree arg, hashval_t val) val = iterative_hash_object (code, val); return iterative_hash_template_arg (TREE_OPERAND (arg, 2), val); + case ARRAY_TYPE: + /* layout_type sets structural equality for arrays of + incomplete type, so we can't rely on the canonical type + for hashing. */ + val = iterative_hash_template_arg (TREE_TYPE (arg), val); + return iterative_hash_template_arg (TYPE_DOMAIN (arg), val); + default: switch (tclass) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aef38ad..179b08c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-12-28 Jason Merrill <jason@redhat.com> + + PR c++/42447 + * g++.dg/template/array21.C: New. + 2009-12-28 Janus Weil <janus@gcc.gnu.org> PR fortran/42353 diff --git a/gcc/testsuite/g++.dg/template/array21.C b/gcc/testsuite/g++.dg/template/array21.C new file mode 100644 index 0000000..5c5f2f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array21.C @@ -0,0 +1,50 @@ +// PR c++/42447 + +template<int> + void* get(int); + +template<typename> + struct unique_ptr; + +template<typename _Tp> + struct unique_ptr<_Tp[]> + { + typedef int __tuple_type; + + void* + get() const + { return ::get<0>(_M_t); } + + __tuple_type _M_t; + }; + +template <typename T> class dynamic_dispatch; + +template <typename TC> + struct dynamic_dispatch<void (TC::*)(int&)> + { + struct entry { }; + unique_ptr<entry[]> m_Start; + + template <typename UC> + void attach_handler(void (UC::*m)(int&)) + { + entry* p = 0; + do { + } while(--p != m_Start.get()); + } + }; + +template <typename TC> + class request_dispatcher + : private dynamic_dispatch<void (TC::*)(int&)> + { request_dispatcher(); }; + +struct file_reader +{ + void execute_command(int&); +}; + +template <> + request_dispatcher<file_reader>::request_dispatcher() + { this->attach_handler(&file_reader::execute_command); } |