aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1995-11-29 10:57:22 -0800
committerJim Wilson <wilson@gcc.gnu.org>1995-11-29 10:57:22 -0800
commit7afbf31f02054b3b2977b5d6e511de71c192e7e6 (patch)
treeb4d702df6539f28bc793cf8483a118bbbe81efe2 /gcc
parent771d55a31cea6a2791f8dad131681953f8a76845 (diff)
downloadgcc-7afbf31f02054b3b2977b5d6e511de71c192e7e6.zip
gcc-7afbf31f02054b3b2977b5d6e511de71c192e7e6.tar.gz
gcc-7afbf31f02054b3b2977b5d6e511de71c192e7e6.tar.bz2
(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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c71
1 files changed, 38 insertions, 33 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index e9d6b2a..d76e724 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -166,6 +166,43 @@ qualify_type (type, like)
return c_build_type_variant (type, constflag, volflag);
}
+/* Return an attribute list that is the union of a1 and a2. */
+tree
+merge_attributes (a1, a2)
+ register tree a1, a2;
+{
+ tree attributes;
+
+ /* Either one unset? Take the set one. */
+
+ if (! (attributes = a1))
+ attributes = a2;
+
+ /* One that completely contains the other? Take it. */
+
+ else if (a2 && ! attribute_list_contained (a1, a2))
+ if (attribute_list_contained (a2, a1))
+ attributes = a2;
+ else
+ {
+ /* Pick the longest list, and hang on the other list. */
+ /* ??? For the moment we punt on the issue of attrs with args. */
+
+ if (list_length (a1) < list_length (a2))
+ attributes = a2, a2 = a1;
+
+ for (; a2; a2 = TREE_CHAIN (a2))
+ if (lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
+ attributes) == NULL_TREE)
+ {
+ a1 = copy_node (a2);
+ TREE_CHAIN (a1) = attributes;
+ 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
@@ -193,39 +230,7 @@ common_type (t1, t2)
return t1;
/* Merge the attributes */
-
- { register tree a1, a2;
- a1 = TYPE_ATTRIBUTES (t1);
- a2 = TYPE_ATTRIBUTES (t2);
-
- /* Either one unset? Take the set one. */
-
- if (!(attributes = a1))
- attributes = a2;
-
- /* One that completely contains the other? Take it. */
-
- else if (a2 && !attribute_list_contained (a1, a2))
- if (attribute_list_contained (a2, a1))
- attributes = a2;
- else
- {
- /* Pick the longest list, and hang on the other list. */
- /* ??? For the moment we punt on the issue of attrs with args. */
-
- if (list_length (a1) < list_length (a2))
- attributes = a2, a2 = a1;
-
- for (; a2; a2 = TREE_CHAIN (a2))
- if (lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
- attributes) == NULL_TREE)
- {
- a1 = copy_node (a2);
- TREE_CHAIN (a1) = attributes;
- attributes = a1;
- }
- }
- }
+ attributes = merge_attributes (TYPE_ATTRIBUTES (t1), TYPE_ATTRIBUTES (t2));
/* Treat an enum type as the unsigned integer type of the same width. */