aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-05-11 04:38:47 +0000
committerRichard Stallman <rms@gnu.org>1993-05-11 04:38:47 +0000
commit15c76378f688b89a176482e183512783e1395650 (patch)
tree91ab25efac2a992d3e441b37d300e795eeaec87b /gcc
parente1fe03e98f0b3b141e38e06bce3f4aefbbe80b52 (diff)
downloadgcc-15c76378f688b89a176482e183512783e1395650.zip
gcc-15c76378f688b89a176482e183512783e1395650.tar.gz
gcc-15c76378f688b89a176482e183512783e1395650.tar.bz2
(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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree.c55
1 files changed, 47 insertions, 8 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 3953c43..e734a26 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;