aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorKai Tietz <kai.tietz@onevision.com>2008-06-28 12:41:38 +0000
committerKai Tietz <ktietz@gcc.gnu.org>2008-06-28 14:41:38 +0200
commitff1c393bd32f3b018957ba9f552e344ab040f309 (patch)
tree73a050f6f9c39147a8e01cd21051f86e6451b4f0 /gcc/tree.c
parentd74032d9e1ef0a43d3259fcdc8a8ec2b30edacca (diff)
downloadgcc-ff1c393bd32f3b018957ba9f552e344ab040f309.zip
gcc-ff1c393bd32f3b018957ba9f552e344ab040f309.tar.gz
gcc-ff1c393bd32f3b018957ba9f552e344ab040f309.tar.bz2
tree.c (build_varargs_function_type_list): New.
2008-06-28 Kai Tietz <kai.tietz@onevision.com> * tree.c (build_varargs_function_type_list): New. (build_function_type_list_1): New. (build_function_type_list): Use build_function_type_list_1. * tree.h (build_varargs_function_type_list): New. From-SVN: r137221
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c59
1 files changed, 48 insertions, 11 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 91b2ec5..d9e4e7f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5862,23 +5862,26 @@ build_function_type (tree value_type, tree arg_types)
}
/* Build a function type. The RETURN_TYPE is the type returned by the
- function. If additional arguments are provided, they are
- additional argument types. The list of argument types must always
- be terminated by NULL_TREE. */
+ function. If VAARGS is set, no void_type_node is appended to the
+ the list. ARGP muse be alway be terminated be a NULL_TREE. */
-tree
-build_function_type_list (tree return_type, ...)
+static tree
+build_function_type_list_1 (bool vaargs, tree return_type, va_list argp)
{
tree t, args, last;
- va_list p;
-
- va_start (p, return_type);
- t = va_arg (p, tree);
- for (args = NULL_TREE; t != NULL_TREE; t = va_arg (p, tree))
+ t = va_arg (argp, tree);
+ for (args = NULL_TREE; t != NULL_TREE; t = va_arg (argp, tree))
args = tree_cons (NULL_TREE, t, args);
- if (args == NULL_TREE)
+ if (vaargs)
+ {
+ last = args;
+ if (args != NULL_TREE)
+ args = nreverse (args);
+ gcc_assert (args != NULL_TREE && last != void_list_node);
+ }
+ else if (args == NULL_TREE)
args = void_list_node;
else
{
@@ -5888,7 +5891,41 @@ build_function_type_list (tree return_type, ...)
}
args = build_function_type (return_type, args);
+ return args;
+}
+
+/* Build a function type. The RETURN_TYPE is the type returned by the
+ function. If additional arguments are provided, they are
+ additional argument types. The list of argument types must always
+ be terminated by NULL_TREE. */
+
+tree
+build_function_type_list (tree return_type, ...)
+{
+ tree args;
+ va_list p;
+
+ va_start (p, return_type);
+ args = build_function_type_list_1 (false, return_type, p);
+ va_end (p);
+ return args;
+}
+
+/* Build a variable argument function type. The RETURN_TYPE is the
+ type returned by the function. If additional arguments are provided,
+ they are additional argument types. The list of argument types must
+ always be terminated by NULL_TREE. */
+
+tree
+build_varargs_function_type_list (tree return_type, ...)
+{
+ tree args;
+ va_list p;
+
+ va_start (p, return_type);
+ args = build_function_type_list_1 (true, return_type, p);
va_end (p);
+
return args;
}