From 9f0bdc935f2199a2247b9d30858a9262d1a6bfa8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 20 May 2013 13:01:09 -0400 Subject: [PATCH] re PR c++/57325 (ICE in strip_typedefs, at cp/tree.c:1306) PR c++/57325 * tree.c (build_cplus_array_type): Copy layout info if element type is complete. From-SVN: r199113 --- gcc/cp/ChangeLog | 6 ++++ gcc/cp/tree.c | 6 ++-- gcc/testsuite/g++.dg/template/array26.C | 40 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/array26.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7c4547456e..5ea7a27625a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-20 Jason Merrill + + PR c++/57325 + * tree.c (build_cplus_array_type): Copy layout info if element + type is complete. + 2013-05-20 Paolo Carlini PR c++/23608 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 2df2087afb2..9c324e34b31 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -829,10 +829,12 @@ build_cplus_array_type (tree elt_type, tree index_type) if (TYPE_MAIN_VARIANT (t) != m) { - if (COMPLETE_TYPE_P (t) && !COMPLETE_TYPE_P (m)) + if (COMPLETE_TYPE_P (TREE_TYPE (t)) && !COMPLETE_TYPE_P (m)) { /* m was built before the element type was complete, so we - also need to copy the layout info from t. */ + also need to copy the layout info from t. We might + end up doing this multiple times if t is an array of + unknown bound. */ tree size = TYPE_SIZE (t); tree size_unit = TYPE_SIZE_UNIT (t); unsigned int align = TYPE_ALIGN (t); diff --git a/gcc/testsuite/g++.dg/template/array26.C b/gcc/testsuite/g++.dg/template/array26.C new file mode 100644 index 00000000000..6692071694d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array26.C @@ -0,0 +1,40 @@ +// PR c++/57325 + +class valarray { int _M_data; }; +template < typename > struct SimpleJet { valarray partials; }; + +template < class C > struct scoped_ptr_impl +{ + scoped_ptr_impl (C *):data_ () { } + struct Data + { + C ptr; + }; + Data data_; +}; + +template < class, class = int >struct scoped_ptr; +template < class C, class D > struct scoped_ptr +{ + scoped_ptr ():impl_ (0) { } + scoped_ptr_impl < C > impl_; +}; + +template < typename JetsT > void +TestJets (JetsT *) +{ + typedef typename JetsT::JetType JetT; + scoped_ptr < JetT[] > a; +} + +template < typename T > struct SimpleJets +{ + typedef SimpleJet < T > JetType; + scoped_ptr < SimpleJet < T >[] > vars_; +}; + +void fn () +{ + SimpleJets < double >b; + TestJets (&b); +} -- 2.30.2