From: Jakub Jelinek Date: Thu, 27 Apr 2017 13:42:37 +0000 (+0200) Subject: re PR c++/80534 (7.1 RC - internal compiler error: in finish_member_declaration,... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f8a36447dbdf5baafe85f953c261ec35f149dfb7;p=gcc.git re PR c++/80534 (7.1 RC - internal compiler error: in finish_member_declaration, at cp/semantics.c:2963) PR c++/80534 * tree.c (type_cache_hasher::equal): Only compare TYPE_TYPELESS_STORAGE flag on non-aggregate element types. (build_array_type_1): Only hash TYPE_TYPELESS_STORAGE flag on non-aggregate element types. * tree.h (TYPE_TYPELESS_STORAGE): Fix comment typo, add more details about the flag on ARRAY_TYPEs in the comment, formatting fix. c-family/ * c-common.c (complete_array_type): Only hash TYPE_TYPELESS_STORAGE flag on non-aggregate element types. testsuite/ * g++.dg/other/pr80534-1.C: New test. * g++.dg/other/pr80534-2.C: New test. From-SVN: r247334 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ac9a03c8307..01976259709 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-04-27 Jakub Jelinek + + PR c++/80534 + * tree.c (type_cache_hasher::equal): Only compare + TYPE_TYPELESS_STORAGE flag on non-aggregate element types. + (build_array_type_1): Only hash TYPE_TYPELESS_STORAGE flag on + non-aggregate element types. + * tree.h (TYPE_TYPELESS_STORAGE): Fix comment typo, add more details + about the flag on ARRAY_TYPEs in the comment, formatting fix. + 2017-04-27 Richard Biener PR middle-end/80533 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 58f554961b6..8f6f55b73bf 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-04-27 Jakub Jelinek + + PR c++/80534 + * c-common.c (complete_array_type): Only hash TYPE_TYPELESS_STORAGE + flag on non-aggregate element types. + 2017-04-25 Bernd Edlinger * c-common.c (c_type_hasher, type_hash_table): Remove. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 9691da75239..4c91103f083 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6371,7 +6371,8 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) inchash::hash hstate; hstate.add_object (TYPE_HASH (unqual_elt)); hstate.add_object (TYPE_HASH (TYPE_DOMAIN (main_type))); - hstate.add_flag (TYPE_TYPELESS_STORAGE (main_type)); + if (!AGGREGATE_TYPE_P (unqual_elt)) + hstate.add_flag (TYPE_TYPELESS_STORAGE (main_type)); main_type = type_hash_canon (hstate.end (), main_type); /* Fix the canonical type. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a28e1a90634..e97e20ca964 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-04-27 Jakub Jelinek + + PR c++/80534 + * g++.dg/other/pr80534-1.C: New test. + * g++.dg/other/pr80534-2.C: New test. + 2017-04-27 Richard Biener PR middle-end/80539 diff --git a/gcc/testsuite/g++.dg/other/pr80534-1.C b/gcc/testsuite/g++.dg/other/pr80534-1.C new file mode 100644 index 00000000000..a8545a7b65f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr80534-1.C @@ -0,0 +1,21 @@ +// PR c++/80534 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template struct A { + struct type { + char __data[0]; + }; +}; +template struct B; +template struct B<_Tp[], _Dp> { + _Tp _M_t; + using pointer = int; + void m_fn1() {} +}; +struct C { + using Storage = A<0>::type; + using StorageUniquePointer = B; + void m_fn2() { storageUniquePointer_.m_fn1(); } + StorageUniquePointer storageUniquePointer_; +}; diff --git a/gcc/testsuite/g++.dg/other/pr80534-2.C b/gcc/testsuite/g++.dg/other/pr80534-2.C new file mode 100644 index 00000000000..e56e7e0a9ae --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr80534-2.C @@ -0,0 +1,27 @@ +// PR c++/80534 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template struct aligned_storage { + struct type { + char __data[0]; + }; +}; +struct A {}; +template struct unique_ptr; +template struct unique_ptr<_Tp[], _Dp> { + int _M_t; + void get() { _M_t; } +}; +struct B { + using Association = A; + using Storage = aligned_storage::type; + using StorageUniquePointer = unique_ptr; + void getAssociationsBegin() { storageUniquePointer_.get(); } + StorageUniquePointer storageUniquePointer_; +}; +struct C {}; +using MainThreadStaticSignalsReceiver = C; +aligned_storage::type + mainThreadStaticSignalsReceiverStorage; diff --git a/gcc/tree.c b/gcc/tree.c index 826af99a9b9..bef0071d087 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7073,9 +7073,16 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) break; return 0; case ARRAY_TYPE: - return (TYPE_TYPELESS_STORAGE (a->type) - == TYPE_TYPELESS_STORAGE (b->type) - && TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type)); + /* Don't compare TYPE_TYPELESS_STORAGE flag on aggregates, + where the flag should be inherited from the element type + and can change after ARRAY_TYPEs are created; on non-aggregates + compare it and hash it, scalars will never have that flag set + and we need to differentiate between arrays created by different + front-ends or middle-end created arrays. */ + return (TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type) + && (AGGREGATE_TYPE_P (TREE_TYPE (a->type)) + || (TYPE_TYPELESS_STORAGE (a->type) + == TYPE_TYPELESS_STORAGE (b->type)))); case RECORD_TYPE: case UNION_TYPE: @@ -8386,7 +8393,8 @@ build_array_type_1 (tree elt_type, tree index_type, bool typeless_storage, hstate.add_object (TYPE_HASH (elt_type)); if (index_type) hstate.add_object (TYPE_HASH (index_type)); - hstate.add_flag (typeless_storage); + if (!AGGREGATE_TYPE_P (elt_type)) + hstate.add_flag (TYPE_TYPELESS_STORAGE (t)); t = type_hash_canon (hstate.end (), t); } diff --git a/gcc/tree.h b/gcc/tree.h index 4ff19ce6f82..6851cd7e0fc 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2037,10 +2037,16 @@ extern machine_mode element_mode (const_tree t); /* For an ARRAY_TYPE, a RECORD_TYPE, a UNION_TYPE or a QUAL_UNION_TYPE whether the array is typeless storage or the type contains a member - with this flag set. Such types are excempt from type-based alias - analysis. */ + with this flag set. Such types are exempt from type-based alias + analysis. For ARRAY_TYPEs with AGGREGATE_TYPE_P element types + the flag should be inherited from the element type, can change + when type is finalized and because of that should not be used in + type hashing. For ARRAY_TYPEs with non-AGGREGATE_TYPE_P element types + the flag should not be changed after the array is created and should + be used in type hashing. */ #define TYPE_TYPELESS_STORAGE(NODE) \ - (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, ARRAY_TYPE)->type_common.typeless_storage) + (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, \ + ARRAY_TYPE)->type_common.typeless_storage) /* Indicated that objects of this type should be laid out in as compact a way as possible. */