From: Jakub Jelinek Date: Thu, 20 Apr 2017 09:18:02 +0000 (+0200) Subject: re PR middle-end/80423 (GC related -fcompare-debug failure) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8a59d4660c63665613f17e2b56da6bf5a4c5c214;p=gcc.git re PR middle-end/80423 (GC related -fcompare-debug failure) PR middle-end/80423 * tree.h (build_array_type): Add typeless_storage default argument. * tree.c (type_cache_hasher::equal): Also compare TYPE_TYPELESS_STORAGE flag for ARRAY_TYPEs. (build_array_type): Add typeless_storage argument, set TYPE_TYPELESS_STORAGE to it, if shared also hash it, and pass to recursive call. (build_nonshared_array_type): Adjust build_array_type_1 caller. (build_array_type): Likewise. Add typeless_storage argument. c-family/ * c-common.c (complete_array_type): Preserve TYPE_TYPELESS_STORAGE. cp/ * tree.c (build_cplus_array_type): Call build_array_type with the intended TYPE_TYPELESS_STORAGE flag value, instead of calling build_array_type and modifying later TYPE_TYPELESS_STORAGE on the shared type. testsuite/ * g++.dg/other/pr80423.C: New test. From-SVN: r247014 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index de76f8a83f4..e650e01f5a7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2017-04-20 Jakub Jelinek + + PR middle-end/80423 + * tree.h (build_array_type): Add typeless_storage default argument. + * tree.c (type_cache_hasher::equal): Also compare + TYPE_TYPELESS_STORAGE flag for ARRAY_TYPEs. + (build_array_type): Add typeless_storage argument, set + TYPE_TYPELESS_STORAGE to it, if shared also hash it, and pass to + recursive call. + (build_nonshared_array_type): Adjust build_array_type_1 caller. + (build_array_type): Likewise. Add typeless_storage argument. + 2017-04-19 Eric Botcazou Jakub Jelinek diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 10cf7617acb..ae987057362 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-04-20 Jakub Jelinek + + PR middle-end/80423 + * c-common.c (complete_array_type): Preserve TYPE_TYPELESS_STORAGE. + 2017-04-18 Jakub Jelinek PR middle-end/79788 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 26d5be370d1..782a4449608 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6386,7 +6386,6 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) { tree maxindex, type, main_type, elt, unqual_elt; int failure = 0, quals; - hashval_t hashcode = 0; bool overflow_p = false; maxindex = size_zero_node; @@ -6480,13 +6479,15 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) TYPE_DOMAIN (main_type) = build_range_type (TREE_TYPE (maxindex), build_int_cst (TREE_TYPE (maxindex), 0), maxindex); + TYPE_TYPELESS_STORAGE (main_type) = TYPE_TYPELESS_STORAGE (type); layout_type (main_type); /* Make sure we have the canonical MAIN_TYPE. */ - hashcode = iterative_hash_object (TYPE_HASH (unqual_elt), hashcode); - hashcode = iterative_hash_object (TYPE_HASH (TYPE_DOMAIN (main_type)), - hashcode); - main_type = type_hash_canon (hashcode, main_type); + 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)); + main_type = type_hash_canon (hstate.end (), main_type); /* Fix the canonical type. */ if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (main_type)) @@ -6497,7 +6498,8 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) != TYPE_DOMAIN (main_type))) TYPE_CANONICAL (main_type) = build_array_type (TYPE_CANONICAL (TREE_TYPE (main_type)), - TYPE_CANONICAL (TYPE_DOMAIN (main_type))); + TYPE_CANONICAL (TYPE_DOMAIN (main_type)), + TYPE_TYPELESS_STORAGE (main_type)); else TYPE_CANONICAL (main_type) = main_type; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6eac0ba0ca0..ec4bb86044a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2017-04-20 Jakub Jelinek + + PR middle-end/80423 + * tree.c (build_cplus_array_type): Call build_array_type + with the intended TYPE_TYPELESS_STORAGE flag value, instead + of calling build_array_type and modifying later TYPE_TYPELESS_STORAGE + on the shared type. + 2017-04-18 Marek Polacek PR c++/80244 - ICE with attribute in template alias. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f1b0a57e158..15b3ad93b2c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -949,14 +949,14 @@ build_cplus_array_type (tree elt_type, tree index_type) } else { - t = build_array_type (elt_type, index_type); - if (elt_type == unsigned_char_type_node - || elt_type == signed_char_type_node - || elt_type == char_type_node - || (TREE_CODE (elt_type) == ENUMERAL_TYPE - && TYPE_CONTEXT (elt_type) == std_node - && !strcmp ("byte", TYPE_NAME_STRING (elt_type)))) - TYPE_TYPELESS_STORAGE (t) = 1; + bool typeless_storage + = (elt_type == unsigned_char_type_node + || elt_type == signed_char_type_node + || elt_type == char_type_node + || (TREE_CODE (elt_type) == ENUMERAL_TYPE + && TYPE_CONTEXT (elt_type) == std_node + && !strcmp ("byte", TYPE_NAME_STRING (elt_type)))); + t = build_array_type (elt_type, index_type, typeless_storage); } /* Now check whether we already have this array variant. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 780adbcbfc1..2299ad1f5df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-20 Jakub Jelinek + + PR middle-end/80423 + * g++.dg/other/pr80423.C: New test. + 2017-04-19 Senthil Kumar Selvaraj * gcc.dg/pr80170.c: Require ptr32plus. diff --git a/gcc/testsuite/g++.dg/other/pr80423.C b/gcc/testsuite/g++.dg/other/pr80423.C new file mode 100644 index 00000000000..a855114fa6d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr80423.C @@ -0,0 +1,11 @@ +// PR middle-end/80423 +// { dg-do compile { target c++11 } } + +typedef unsigned char uint8_t; +struct A { + template A(unsigned char (&)[N]); +}; +void fn1(A) { + uint8_t a[]{0}; + fn1(a); +} diff --git a/gcc/tree.c b/gcc/tree.c index c18889caeb5..72dbba4daad 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7073,7 +7073,9 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) break; return 0; case ARRAY_TYPE: - return TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type); + return (TYPE_TYPELESS_STORAGE (a->type) + == TYPE_TYPELESS_STORAGE (b->type) + && TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type)); case RECORD_TYPE: case UNION_TYPE: @@ -8350,10 +8352,12 @@ subrange_type_for_debug_p (const_tree type, tree *lowval, tree *highval) /* Construct, lay out and return the type of arrays of elements with ELT_TYPE and number of elements specified by the range of values of INDEX_TYPE. + If TYPELESS_STORAGE is true, TYPE_TYPELESS_STORAGE flag is set on the type. If SHARED is true, reuse such a type that has already been constructed. */ static tree -build_array_type_1 (tree elt_type, tree index_type, bool shared) +build_array_type_1 (tree elt_type, tree index_type, bool typeless_storage, + bool shared) { tree t; @@ -8367,6 +8371,7 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared) TREE_TYPE (t) = elt_type; TYPE_DOMAIN (t) = index_type; TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (elt_type); + TYPE_TYPELESS_STORAGE (t) = typeless_storage; layout_type (t); /* If the element type is incomplete at this point we get marked for @@ -8381,6 +8386,7 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared) hstate.add_object (TYPE_HASH (elt_type)); if (index_type) hstate.add_object (TYPE_HASH (index_type)); + hstate.add_flag (typeless_storage); t = type_hash_canon (hstate.end (), t); } @@ -8396,7 +8402,7 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared) = build_array_type_1 (TYPE_CANONICAL (elt_type), index_type ? TYPE_CANONICAL (index_type) : NULL_TREE, - shared); + typeless_storage, shared); } return t; @@ -8405,9 +8411,9 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared) /* Wrapper around build_array_type_1 with SHARED set to true. */ tree -build_array_type (tree elt_type, tree index_type) +build_array_type (tree elt_type, tree index_type, bool typeless_storage) { - return build_array_type_1 (elt_type, index_type, true); + return build_array_type_1 (elt_type, index_type, typeless_storage, true); } /* Wrapper around build_array_type_1 with SHARED set to false. */ @@ -8415,7 +8421,7 @@ build_array_type (tree elt_type, tree index_type) tree build_nonshared_array_type (tree elt_type, tree index_type) { - return build_array_type_1 (elt_type, index_type, false); + return build_array_type_1 (elt_type, index_type, false, false); } /* Return a representation of ELT_TYPE[NELTS], using indices of type diff --git a/gcc/tree.h b/gcc/tree.h index 50a674bf0fe..b136f5cce6b 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4068,7 +4068,7 @@ extern tree build_truth_vector_type (unsigned, unsigned); extern tree build_same_sized_truth_vector_type (tree vectype); extern tree build_opaque_vector_type (tree innertype, int nunits); extern tree build_index_type (tree); -extern tree build_array_type (tree, tree); +extern tree build_array_type (tree, tree, bool = false); extern tree build_nonshared_array_type (tree, tree); extern tree build_array_type_nelts (tree, unsigned HOST_WIDE_INT); extern tree build_function_type (tree, tree);