From: Jakub Jelinek Date: Tue, 29 Jul 2008 16:29:33 +0000 (+0200) Subject: re PR c++/36852 (Two dimensional array in template method argument list incorrectly... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eb9c434c0fa298c0fcb7172f5761970891dead8a;p=gcc.git re PR c++/36852 (Two dimensional array in template method argument list incorrectly interpreted.) PR c++/36852 * tree.c (cplus_array_hash, build_cplus_array_type_1): Hash on TYPE_UID instead of pointers. * g++.dg/pch/array-1.C: New test. * g++.dg/pch/array-1.Hs: New file. From-SVN: r138250 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6fe401a759b..e05b0cb8d94 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-07-29 Jakub Jelinek + + PR c++/36852 + * tree.c (cplus_array_hash, build_cplus_array_type_1): Hash on + TYPE_UID instead of pointers. + 2008-07-29 Jan Hubicka * optimize.c (maybe_clone_body): Remove DECL_INLINE. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0522ae2786f..50c3049c3d0 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -504,9 +504,9 @@ cplus_array_hash (const void* k) hashval_t hash; const_tree const t = (const_tree) k; - hash = (htab_hash_pointer (TREE_TYPE (t)) - ^ htab_hash_pointer (TYPE_DOMAIN (t))); - + hash = TYPE_UID (TREE_TYPE (t)); + if (TYPE_DOMAIN (t)) + hash ^= TYPE_UID (TYPE_DOMAIN (t)); return hash; } @@ -553,8 +553,9 @@ build_cplus_array_type_1 (tree elt_type, tree index_type) cplus_array_htab = htab_create_ggc (61, &cplus_array_hash, &cplus_array_compare, NULL); - hash = (htab_hash_pointer (elt_type) - ^ htab_hash_pointer (index_type)); + hash = TYPE_UID (elt_type); + if (index_type) + hash ^= TYPE_UID (index_type); cai.type = elt_type; cai.domain = index_type; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cba3ac04df1..d4e8ddb8701 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-07-29 Jakub Jelinek + + PR c++/36852 + * g++.dg/pch/array-1.C: New test. + * g++.dg/pch/array-1.Hs: New file. + 2008-07-29 Jan Hubicka * gcc.dg/20040206-1.c: Expect frontend warning now. diff --git a/gcc/testsuite/g++.dg/pch/array-1.C b/gcc/testsuite/g++.dg/pch/array-1.C new file mode 100644 index 00000000000..a8935ed2606 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/array-1.C @@ -0,0 +1,15 @@ +// PR c++/36852 + +#include "array-1.H" + +template +T +A::foo (T t[3][3]) +{ + return t[0][1]; +} + +int +main () +{ +} diff --git a/gcc/testsuite/g++.dg/pch/array-1.Hs b/gcc/testsuite/g++.dg/pch/array-1.Hs new file mode 100644 index 00000000000..fb44b675e3a --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/array-1.Hs @@ -0,0 +1,4 @@ +struct A +{ + template static T foo (T[3][3]); +};