Commit 7afbf31f by Jim Wilson

(merge_attributes): New function.

(merge_attributes): New function.  Move code from
common_type to here.
(common_type): Call merge_attributes instead of having inline code.

From-SVN: r10620
parent 771d55a3
...@@ -166,46 +166,21 @@ qualify_type (type, like) ...@@ -166,46 +166,21 @@ qualify_type (type, like)
return c_build_type_variant (type, constflag, volflag); return c_build_type_variant (type, constflag, volflag);
} }
/* Return the common type of two types. /* Return an attribute list that is the union of a1 and a2. */
We assume that comptypes has already been done and returned 1;
if that isn't so, this may crash. In particular, we assume that qualifiers
match.
This is the type for the result of most arithmetic operations
if the operands have the given two types. */
tree tree
common_type (t1, t2) merge_attributes (a1, a2)
tree t1, t2; register tree a1, a2;
{ {
register enum tree_code code1;
register enum tree_code code2;
tree attributes; tree attributes;
/* Save time if the two types are the same. */
if (t1 == t2) return t1;
/* If one type is nonsense, use the other. */
if (t1 == error_mark_node)
return t2;
if (t2 == error_mark_node)
return t1;
/* Merge the attributes */
{ register tree a1, a2;
a1 = TYPE_ATTRIBUTES (t1);
a2 = TYPE_ATTRIBUTES (t2);
/* Either one unset? Take the set one. */ /* Either one unset? Take the set one. */
if (!(attributes = a1)) if (! (attributes = a1))
attributes = a2; attributes = a2;
/* One that completely contains the other? Take it. */ /* One that completely contains the other? Take it. */
else if (a2 && !attribute_list_contained (a1, a2)) else if (a2 && ! attribute_list_contained (a1, a2))
if (attribute_list_contained (a2, a1)) if (attribute_list_contained (a2, a1))
attributes = a2; attributes = a2;
else else
...@@ -225,7 +200,37 @@ common_type (t1, t2) ...@@ -225,7 +200,37 @@ common_type (t1, t2)
attributes = a1; attributes = a1;
} }
} }
} return attributes;
}
/* Return the common type of two types.
We assume that comptypes has already been done and returned 1;
if that isn't so, this may crash. In particular, we assume that qualifiers
match.
This is the type for the result of most arithmetic operations
if the operands have the given two types. */
tree
common_type (t1, t2)
tree t1, t2;
{
register enum tree_code code1;
register enum tree_code code2;
tree attributes;
/* Save time if the two types are the same. */
if (t1 == t2) return t1;
/* If one type is nonsense, use the other. */
if (t1 == error_mark_node)
return t2;
if (t2 == error_mark_node)
return t1;
/* Merge the attributes */
attributes = merge_attributes (TYPE_ATTRIBUTES (t1), TYPE_ATTRIBUTES (t2));
/* Treat an enum type as the unsigned integer type of the same width. */ /* Treat an enum type as the unsigned integer type of the same width. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment