From: Richard Stallman Date: Tue, 11 May 1993 04:38:47 +0000 (+0000) Subject: (change_main_variant): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=15c76378f688b89a176482e183512783e1395650;p=gcc.git (change_main_variant): New function. (build_array_type): Use that to set the TYPE_MAIN_VARIANT. (real_value_from_int_cst): If I is unsigned, use REAL_VALUE_FROM_UNSIGNED_INT. From-SVN: r4418 --- diff --git a/gcc/tree.c b/gcc/tree.c index 3953c43b83c..e734a26d79e 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1155,7 +1155,10 @@ real_value_from_int_cst (i) { REAL_VALUE_TYPE d; #ifdef REAL_ARITHMETIC - REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i)); + if (! TREE_UNSIGNED (TREE_TYPE (i))) + REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i)); + else + REAL_VALUE_FROM_UNSIGNED_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i)); #else /* not REAL_ARITHMETIC */ if (TREE_INT_CST_HIGH (i) < 0 && ! TREE_UNSIGNED (TREE_TYPE (i))) { @@ -2269,6 +2272,34 @@ build_type_variant (type, constp, volatilep) return t; } +/* Give TYPE a new main variant: NEW_MAIN. + This is the right thing to do only when something else + about TYPE is modified in place. */ + +tree +change_main_variant (type, new_main) + tree type, new_main; +{ + tree t; + tree omain = TYPE_MAIN_VARIANT (type); + + /* Remove TYPE from the TYPE_NEXT_VARIANT chain of its main variant. */ + if (TYPE_NEXT_VARIANT (omain) == type) + TYPE_NEXT_VARIANT (omain) = TYPE_NEXT_VARIANT (type); + else + for (t = TYPE_NEXT_VARIANT (omain); t && TYPE_NEXT_VARIANT (t); + t = TYPE_NEXT_VARIANT (t)) + if (TYPE_NEXT_VARIANT (t) == type) + { + TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (type); + break; + } + + TYPE_MAIN_VARIANT (type) = new_main; + TYPE_NEXT_VARIANT (type) = TYPE_NEXT_VARIANT (new_main); + TYPE_NEXT_VARIANT (new_main) = type; +} + /* Create a new variant of TYPE, equivalent but distinct. This is so the caller can modify it. */ @@ -2792,18 +2823,26 @@ build_array_type (elt_type, index_type) TREE_TYPE (t) = elt_type; TYPE_DOMAIN (t) = index_type; - /* The main variant of an array type should always - be an array whose element type is the main variant. */ - if (elt_type != TYPE_MAIN_VARIANT (elt_type)) - TYPE_MAIN_VARIANT (t) = build_array_type (TYPE_MAIN_VARIANT (elt_type), - index_type); - if (index_type == 0) - return t; + { + /* The main variant of an array type should always + be an array whose element type is the main variant. */ + if (elt_type != TYPE_MAIN_VARIANT (elt_type)) + change_main_variant (t, build_array_type (TYPE_MAIN_VARIANT (elt_type), + index_type)); + + return t; + } hashcode = TYPE_HASH (elt_type) + TYPE_HASH (index_type); t = type_hash_canon (hashcode, t); + /* The main variant of an array type should always + be an array whose element type is the main variant. */ + if (elt_type != TYPE_MAIN_VARIANT (elt_type)) + change_main_variant (t, build_array_type (TYPE_MAIN_VARIANT (elt_type), + index_type)); + if (TYPE_SIZE (t) == 0) layout_type (t); return t;