From e3a07cda8df51224d900667a50dc87bfffde1fa9 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 17 Jul 2012 21:34:22 +0000 Subject: [PATCH] PR c++/53989 * tree.c (build_cplus_array_type): Also add TYPE_CANONICAL to the list of variants. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@189588 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/tree.c | 11 +++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/array23.C | 12 ++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/array23.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1003d4b1a9..9daf2e03cba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2012-07-17 Jason Merrill + PR c++/53989 + * tree.c (build_cplus_array_type): Also add TYPE_CANONICAL + to the list of variants. + +2012-07-17 Jason Merrill + PR c++/53549 * parser.c (cp_parser_class_head): Call xref_basetypes here. (cp_parser_class_specifier_1): Not here. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0d47578ab5a..1e98f85d18c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -794,12 +794,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 5a8fdea5b48..886661c428b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2012-07-17 Jason Merrill + PR c++/53989 + * g++.dg/template/array23.C: New. + +2012-07-17 Jason Merrill + PR c++/53549 * g++.dg/template/current-inst1.C: New. * g++.dg/parse/crash35.C: Adjust. diff --git a/gcc/testsuite/g++.dg/template/array23.C b/gcc/testsuite/g++.dg/template/array23.C new file mode 100644 index 00000000000..6ede8b07773 --- /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); +} -- 2.11.0