aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>2003-08-25 16:58:31 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-08-25 16:58:31 +0000
commit1281fe11033eebaaa8a4fbc70770eca204c9c504 (patch)
tree47ae12295f5ab583fc99e8676bc65561081e359a /gcc/tree.c
parent43dc123f52541ec779e4b56541203cec16c18d80 (diff)
downloadgcc-1281fe11033eebaaa8a4fbc70770eca204c9c504.zip
gcc-1281fe11033eebaaa8a4fbc70770eca204c9c504.tar.gz
gcc-1281fe11033eebaaa8a4fbc70770eca204c9c504.tar.bz2
re PR target/8795 ([PPC] Altivec related bugs concerning gcc 3.3 and mainline)
PR c++/8795 * tree.h (build_method_type_directly): Declare. * c-common.c (handle_vector_size_attributes): Handle METHOD_TYPEs. (vector_size_helper): Likewise. * tree.c (build_method_type_directly): New function. (build_method_type): Use it. From-SVN: r70774
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index d38a87d..a12df1c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3850,35 +3850,37 @@ build_function_type_list (tree return_type, ...)
return args;
}
-/* Construct, lay out and return the type of methods belonging to class
- BASETYPE and whose arguments and values are described by TYPE.
- If that type exists already, reuse it.
- TYPE must be a FUNCTION_TYPE node. */
+/* Build a METHOD_TYPE for a member of BASETYPE. The RETTYPE (a TYPE)
+ and ARGTYPES (a TREE_LIST) are the return type and arguments types
+ for the method. An implicit additional parameter (of type
+ pointer-to-BASETYPE) is added to the ARGTYPES. */
tree
-build_method_type (tree basetype, tree type)
+build_method_type_directly (tree basetype,
+ tree rettype,
+ tree argtypes)
{
tree t;
- unsigned int hashcode;
+ tree ptype;
+ int hashcode;
/* Make a node of the sort we want. */
t = make_node (METHOD_TYPE);
- if (TREE_CODE (type) != FUNCTION_TYPE)
- abort ();
-
TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
- TREE_TYPE (t) = TREE_TYPE (type);
+ TREE_TYPE (t) = rettype;
+ ptype = build_pointer_type (basetype);
/* The actual arglist for this function includes a "hidden" argument
which is "this". Put it into the list of argument types. */
+ argtypes = tree_cons (NULL_TREE, ptype, argtypes);
+ TYPE_ARG_TYPES (t) = argtypes;
- TYPE_ARG_TYPES (t)
- = tree_cons (NULL_TREE,
- build_pointer_type (basetype), TYPE_ARG_TYPES (type));
+ /* If we already have such a type, use the old one and free this one.
+ Note that it also frees up the above cons cell if found. */
+ hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) +
+ type_hash_list (argtypes);
- /* If we already have such a type, use the old one and free this one. */
- hashcode = TYPE_HASH (basetype) + TYPE_HASH (type);
t = type_hash_canon (hashcode, t);
if (!COMPLETE_TYPE_P (t))
@@ -3887,6 +3889,22 @@ build_method_type (tree basetype, tree type)
return t;
}
+/* Construct, lay out and return the type of methods belonging to class
+ BASETYPE and whose arguments and values are described by TYPE.
+ If that type exists already, reuse it.
+ TYPE must be a FUNCTION_TYPE node. */
+
+tree
+build_method_type (tree basetype, tree type)
+{
+ if (TREE_CODE (type) != FUNCTION_TYPE)
+ abort ();
+
+ return build_method_type_directly (basetype,
+ TREE_TYPE (type),
+ TYPE_ARG_TYPES (type));
+}
+
/* Construct, lay out and return the type of offsets to a value
of type TYPE, within an object of type BASETYPE.
If a suitable offset type exists already, reuse it. */