From 021ed367a561125c90bef393b0a641d3cc9a7d51 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 16 Oct 2009 11:44:46 +0000 Subject: [PATCH] gimple.c (gimple_types_compatible_p): Restrict completing types to record or unions. 2009-10-16 Richard Guenther * gimple.c (gimple_types_compatible_p): Restrict completing types to record or unions. Simplify completion. Do not merge records or unions with different TYPE_STRUCTURAL_EQUALITY_P tag. (iterative_hash_gimple_type): Restrict non-recursing into pointer targets for records and unions. From-SVN: r152898 --- gcc/ChangeLog | 9 +++++++++ gcc/gimple.c | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2c8dff8cf498..a0f0ce3a7390 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2009-10-16 Richard Guenther + + * gimple.c (gimple_types_compatible_p): Restrict completing + types to record or unions. Simplify completion. + Do not merge records or unions with different + TYPE_STRUCTURAL_EQUALITY_P tag. + (iterative_hash_gimple_type): Restrict non-recursing into + pointer targets for records and unions. + 2009-10-15 Jakub Jelinek PR debug/41717 diff --git a/gcc/gimple.c b/gcc/gimple.c index e953066dafbb..105fb1b60613 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3413,13 +3413,17 @@ gimple_types_compatible_p (tree t1, tree t2) /* If one pointer points to an incomplete type variant of the other pointed-to type they are the same. */ if (TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2)) + && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t1)) && (!COMPLETE_TYPE_P (TREE_TYPE (t1)) || !COMPLETE_TYPE_P (TREE_TYPE (t2))) && compare_type_names_p (TREE_TYPE (t1), TREE_TYPE (t2), true)) { - /* If t2 is complete we want to choose it instead of t1. */ + /* Replace the pointed-to incomplete type with the + complete one. */ if (COMPLETE_TYPE_P (TREE_TYPE (t2))) - gimple_force_type_merge (TREE_TYPE (t1), TREE_TYPE (t2)); + TREE_TYPE (t1) = TREE_TYPE (t2); + else + TREE_TYPE (t2) = TREE_TYPE (t1); goto same_types; } @@ -3470,6 +3474,12 @@ gimple_types_compatible_p (tree t1, tree t2) { tree f1, f2; + /* If one type requires structural equality checks and the + other doesn't, do not merge the types. */ + if (TYPE_STRUCTURAL_EQUALITY_P (t1) + != TYPE_STRUCTURAL_EQUALITY_P (t2)) + goto different_types; + /* The struct tags shall compare equal. */ if (!compare_type_names_p (TYPE_MAIN_VARIANT (t1), TYPE_MAIN_VARIANT (t2), false)) @@ -3667,7 +3677,7 @@ iterative_hash_gimple_type (tree type, hashval_t val, avoid hash differences for complete vs. incomplete types. */ if (POINTER_TYPE_P (type)) { - if (AGGREGATE_TYPE_P (TREE_TYPE (type))) + if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type))) { v = iterative_hash_hashval_t (TREE_CODE (TREE_TYPE (type)), v); v = iterative_hash_name