From: Jason Merrill Date: Tue, 17 Jul 2012 21:34:06 +0000 (-0400) Subject: re PR c++/53989 (Internal compiler error in strip_typedefs, at cp/tree.c:1187) X-Git-Tag: releases/gcc-4.8.0~4432 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=697c474c8fadce131f79b662a79a454959d02c39;p=thirdparty%2Fgcc.git re PR c++/53989 (Internal compiler error in strip_typedefs, at cp/tree.c:1187) PR c++/53989 * tree.c (build_cplus_array_type): Also add TYPE_CANONICAL to the list of variants. From-SVN: r189587 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3325f1a12e1d..c1465ccc385d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-07-17 Jason Merrill + PR c++/53989 + * tree.c (build_cplus_array_type): Also add TYPE_CANONICAL + to the list of variants. + * decl.c (xref_basetypes): Complain about incomplete template base. * class.c (finish_struct): Adjust variants in templates, too. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 01bc48383b45..3c7bbb132f31 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -803,12 +803,23 @@ build_cplus_array_type (tree elt_type, tree index_type) { tree m = build_cplus_array_type (TYPE_MAIN_VARIANT (elt_type), index_type); + tree c = TYPE_CANONICAL (t); + if (TYPE_MAIN_VARIANT (t) != m) { TYPE_MAIN_VARIANT (t) = m; TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); TYPE_NEXT_VARIANT (m) = t; } + + /* If we built a new array type for TYPE_CANONICAL, add + that to the list of variants as well. */ + if (c && c != t && TYPE_MAIN_VARIANT (c) != m) + { + TYPE_MAIN_VARIANT (c) = m; + TYPE_NEXT_VARIANT (c) = t; + TYPE_NEXT_VARIANT (m) = c; + } } /* Push these needs up so that initialization takes place diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70efda9ed5dd..5784918c8d1b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-07-17 Jason Merrill + + PR c++/53989 + * g++.dg/template/array23.C: New. + 2012-07-17 Tobias Burnus PR fortran/53985 diff --git a/gcc/testsuite/g++.dg/template/array23.C b/gcc/testsuite/g++.dg/template/array23.C new file mode 100644 index 000000000000..6ede8b077735 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array23.C @@ -0,0 +1,12 @@ +// PR c++/53989 + +struct Foo { + int value; + typedef Foo Foo2; + static Foo2 const foos[2]; +}; + +template void g (T); +void bar() { + g(&Foo::foos); +}