diff options
author | Jason Merrill <jason@redhat.com> | 2012-07-20 12:11:42 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2012-07-20 12:11:42 -0400 |
commit | 3ebc22c1e408911d3feef73ba8b5a1e2ba489fbb (patch) | |
tree | c50f09207e4e60b41c1786f4e6a950f99331fae3 /gcc/cp/tree.c | |
parent | 824f71b9ff74b82e1c125d98a946ffe9fb4ab319 (diff) | |
download | gcc-3ebc22c1e408911d3feef73ba8b5a1e2ba489fbb.zip gcc-3ebc22c1e408911d3feef73ba8b5a1e2ba489fbb.tar.gz gcc-3ebc22c1e408911d3feef73ba8b5a1e2ba489fbb.tar.bz2 |
re PR c++/54038 (finalize_type_size enters infinite loop becasue TYPE_NEXT_VARIANT (variant) == variant)
PR c++/54038
* tree.c (build_cplus_array_type): Use build_cplus_array_type to build
canonical array type rather than mess with its TYPE_*_VARIANT.
From-SVN: r189719
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 3c7bbb132..83b8ca7 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -795,7 +795,18 @@ build_cplus_array_type (tree elt_type, tree index_type) } } else - t = build_array_type (elt_type, index_type); + { + if (!TYPE_STRUCTURAL_EQUALITY_P (elt_type) + && !(index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type)) + && (TYPE_CANONICAL (elt_type) != elt_type + || (index_type && TYPE_CANONICAL (index_type) != index_type))) + /* Make sure that the canonical type is on the appropriate + variants list. */ + build_cplus_array_type + (TYPE_CANONICAL (elt_type), + index_type ? TYPE_CANONICAL (index_type) : index_type); + t = build_array_type (elt_type, index_type); + } /* We want TYPE_MAIN_VARIANT of an array to strip cv-quals from the element type as well, so fix it up if needed. */ @@ -803,7 +814,6 @@ 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) { @@ -811,15 +821,6 @@ build_cplus_array_type (tree elt_type, tree index_type) 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 |