This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][C] Do not modify possibly shared types
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Thu, 9 Sep 2010 17:37:21 +0200 (CEST)
- Subject: [PATCH][C] Do not modify possibly shared types
This avoids modifying possibly shared (through tree.c type_hash_canon)
types by making distinct copies of them. The code presumably assumes
that this happens as it does SET_TYPE_STRUCTURAL_EQUALITY.
This is needed to allow the tree.c range type cleanups.
Bootstrap and regtest pending on x86_64-unknown-linux-gnu, ok if that
succeeds?
Thanks,
Richard.
2010-09-09 Richard Guenther <rguenther@suse.de>
* c-decl.c (grokdeclarator): When modifying TYPE_SIZE manually
create a distinct copy of the type.
Index: gcc/c-decl.c
===================================================================
*** gcc/c-decl.c (revision 164000)
--- gcc/c-decl.c (working copy)
*************** grokdeclarator (const struct c_declarato
*** 5457,5471 ****
--- 5457,5477 ----
zero. */
if (size && integer_zerop (size))
{
+ int quals = TYPE_QUALS (type);
gcc_assert (itype);
+ type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
+ type = build_qualified_type (type, quals);
TYPE_SIZE (type) = bitsize_zero_node;
TYPE_SIZE_UNIT (type) = size_zero_node;
SET_TYPE_STRUCTURAL_EQUALITY (type);
}
if (array_parm_vla_unspec_p)
{
+ int quals = TYPE_QUALS (type);
gcc_assert (itype);
/* The type is complete. C99 6.7.5.2p4 */
+ type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
+ type = build_qualified_type (type, quals);
TYPE_SIZE (type) = bitsize_zero_node;
TYPE_SIZE_UNIT (type) = size_zero_node;
SET_TYPE_STRUCTURAL_EQUALITY (type);