* [patch] Add to tree.c build_function_type_list_ellipsis()
@ 2008-06-28 9:59 Kai Tietz
2008-06-28 11:33 ` Richard Guenther
0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2008-06-28 9:59 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Guenther
[-- Attachment #1: Type: text/plain, Size: 653 bytes --]
Hello,
This patch adds a function to tree.c/tree.h for creating ellipsis
function.via an easy helper function. This method checks, that at
least one argument is specified and the last argument isn't a
void_type_node. In the latter the function build_function_type_list
has to be used for none wildcard functions.
ChangeLog
2008-06-28 Kai Tietz <kai.tietz@onevision.com>
* tree.c (build_function_type_list_ellipsis): New.
* tree.h (build_function_type_list_ellipsis): New.
Is this patch ok for apply on trunk?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: bfct_ellipsis.txt --]
[-- Type: text/plain, Size: 1804 bytes --]
Index: gcc/gcc/tree.c
===================================================================
--- gcc.orig/gcc/tree.c
+++ gcc/gcc/tree.c
@@ -5892,6 +5892,36 @@ build_function_type_list (tree return_ty
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_ellipsis (tree return_type, ...)
+{
+ tree t, args, l;
+ va_list p;
+
+ va_start (p, return_type);
+
+ l = t = va_arg (p, tree);
+ for (args = NULL_TREE; t != NULL_TREE; t = va_arg (p, tree))
+ {
+ args = tree_cons (NULL_TREE, t, args);
+ l = t;
+ }
+
+ /* Verify that at least on argument was specified and
+ the last argument wasn't a void_type_node. */
+ gcc_assert (args != NULL_TREE && l != void_type_node);
+ args = nreverse (args);
+ args = build_function_type (return_type, args);
+
+ va_end (p);
+ return args;
+}
+
/* 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
Index: gcc/gcc/tree.h
===================================================================
--- gcc.orig/gcc/tree.h
+++ gcc/gcc/tree.h
@@ -4084,6 +4084,7 @@ extern tree build_index_2_type (tree, tr
extern tree build_array_type (tree, tree);
extern tree build_function_type (tree, tree);
extern tree build_function_type_list (tree, ...);
+extern tree build_function_type_list_ellipsis (tree, ...);
extern tree build_method_type_directly (tree, tree, tree);
extern tree build_method_type (tree, tree);
extern tree build_offset_type (tree, tree);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Add to tree.c build_function_type_list_ellipsis()
2008-06-28 9:59 [patch] Add to tree.c build_function_type_list_ellipsis() Kai Tietz
@ 2008-06-28 11:33 ` Richard Guenther
2008-06-28 11:35 ` Kai Tietz
0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2008-06-28 11:33 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Sat, Jun 28, 2008 at 11:25 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> This patch adds a function to tree.c/tree.h for creating ellipsis
> function.via an easy helper function. This method checks, that at
> least one argument is specified and the last argument isn't a
> void_type_node. In the latter the function build_function_type_list
> has to be used for none wildcard functions.
>
> ChangeLog
>
> 2008-06-28 Kai Tietz <kai.tietz@onevision.com>
>
> * tree.c (build_function_type_list_ellipsis): New.
> * tree.h (build_function_type_list_ellipsis): New.
>
> Is this patch ok for apply on trunk?
No. Please split out a common part from build_function_type_list instead, like
static tree
build_function_type_list_1 (bool varargs, tree return_type, va_list args)
{
...
}
and wrap the other two around this like
static tree
build_function_type_list (tree return_type, ...)
{
va_list args = va_start (return_type);
tree res = build_function_type_list_1 (false, return_type, args);
va_end (args);
return res;
}
etc.
> Cheers,
> Kai
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Add to tree.c build_function_type_list_ellipsis()
2008-06-28 11:33 ` Richard Guenther
@ 2008-06-28 11:35 ` Kai Tietz
2008-06-28 12:23 ` Richard Guenther
0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2008-06-28 11:35 UTC (permalink / raw)
To: Richard Guenther; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
Hello,
I changed it the way you suggested. I assume that the static for
build_function_type_list is a typo.
ChangeLog
2008-06-28 Kai Tietz <kai.tietz@onevision.com>
* tree.c (build_function_type_list_ellipsis): New.
(build_function_type_list_1): New.
(build_function_type_list): Use build_function_type_list_1.
* tree.h (build_function_type_list_ellipsis): New.
Is this patch ok for apply on trunk?
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: bfct_ellipsis.txt --]
[-- Type: text/plain, Size: 2866 bytes --]
Index: gcc/gcc/tree.c
===================================================================
--- gcc.orig/gcc/tree.c
+++ gcc/gcc/tree.c
@@ -5862,23 +5862,24 @@ build_function_type (tree value_type, tr
}
/* 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;
+ gcc_assert (args != NULL_TREE && last != void_list_node);
+ }
+ else if (args == NULL_TREE)
args = void_list_node;
else
{
@@ -5888,7 +5889,41 @@ build_function_type_list (tree return_ty
}
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 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_ellipsis (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;
}
Index: gcc/gcc/tree.h
===================================================================
--- gcc.orig/gcc/tree.h
+++ gcc/gcc/tree.h
@@ -4084,6 +4084,7 @@ extern tree build_index_2_type (tree, tr
extern tree build_array_type (tree, tree);
extern tree build_function_type (tree, tree);
extern tree build_function_type_list (tree, ...);
+extern tree build_function_type_list_ellipsis (tree, ...);
extern tree build_method_type_directly (tree, tree, tree);
extern tree build_method_type (tree, tree);
extern tree build_offset_type (tree, tree);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Add to tree.c build_function_type_list_ellipsis()
2008-06-28 11:35 ` Kai Tietz
@ 2008-06-28 12:23 ` Richard Guenther
2008-06-28 12:37 ` Kai Tietz
0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2008-06-28 12:23 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Sat, Jun 28, 2008 at 1:32 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> I changed it the way you suggested. I assume that the static for
> build_function_type_list is a typo.
+/* 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 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. */
Same comment as above? I suggest
/* Build a variable arguments function type. The ....
+tree
+build_function_type_list_ellipsis (tree return_type, ...)
I would say build_varargs_function_type_list is a more appropriate name.
Ok with these changes if you bootstrapped/tested this patch.
Richard.
+{
+ 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;
}
> ChangeLog
>
> 2008-06-28 Kai Tietz <kai.tietz@onevision.com>
>
> * tree.c (build_function_type_list_ellipsis): New.
> (build_function_type_list_1): New.
> (build_function_type_list): Use build_function_type_list_1.
> * tree.h (build_function_type_list_ellipsis): New.
>
> Is this patch ok for apply on trunk?
>
>
>
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Add to tree.c build_function_type_list_ellipsis()
2008-06-28 12:23 ` Richard Guenther
@ 2008-06-28 12:37 ` Kai Tietz
2008-06-28 12:39 ` Richard Guenther
0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2008-06-28 12:37 UTC (permalink / raw)
To: Richard Guenther; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 568 bytes --]
Hello,
I changed the name and the comment as you suggested. I did a bootstrap
for x86_64-pc-mingw32 without seeing any regression.
ChangeLog
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.
Ok for apply?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: bfct_ellipsis.txt --]
[-- Type: text/plain, Size: 2936 bytes --]
Index: gcc/gcc/tree.c
===================================================================
--- gcc.orig/gcc/tree.c
+++ gcc/gcc/tree.c
@@ -5862,23 +5862,26 @@ build_function_type (tree value_type, tr
}
/* 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_ty
}
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;
}
Index: gcc/gcc/tree.h
===================================================================
--- gcc.orig/gcc/tree.h
+++ gcc/gcc/tree.h
@@ -4084,6 +4084,7 @@ extern tree build_index_2_type (tree, tr
extern tree build_array_type (tree, tree);
extern tree build_function_type (tree, tree);
extern tree build_function_type_list (tree, ...);
+extern tree build_varargs_function_type_list (tree, ...);
extern tree build_method_type_directly (tree, tree, tree);
extern tree build_method_type (tree, tree);
extern tree build_offset_type (tree, tree);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Add to tree.c build_function_type_list_ellipsis()
2008-06-28 12:37 ` Kai Tietz
@ 2008-06-28 12:39 ` Richard Guenther
0 siblings, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2008-06-28 12:39 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Sat, Jun 28, 2008 at 2:35 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> I changed the name and the comment as you suggested. I did a bootstrap
> for x86_64-pc-mingw32 without seeing any regression.
>
> ChangeLog
>
> 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.
>
> Ok for apply?
Ok.
Thanks,
Richard.
> Cheers,
> Kai
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-28 12:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-28 9:59 [patch] Add to tree.c build_function_type_list_ellipsis() Kai Tietz
2008-06-28 11:33 ` Richard Guenther
2008-06-28 11:35 ` Kai Tietz
2008-06-28 12:23 ` Richard Guenther
2008-06-28 12:37 ` Kai Tietz
2008-06-28 12:39 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).