Message ID | 1429487100-12607-1-git-send-email-patrick@parcs.ath.cx |
---|---|
State | New |
Headers | show |
On 04/19/2015 07:45 PM, Patrick Palka wrote: > stdarg_p() apparently returns false for a variadic function that has no > concrete parameters, e.g. "void foo (...);". This patch fixes this > issue by removing the predicate's seemingly bogus "n != NULL_TREE" test. What does this do with K&R non-prototype declarations, e.g. "int main();"? Jason
On Sun, Apr 19, 2015 at 11:17 PM, Jason Merrill <jason@redhat.com> wrote: > On 04/19/2015 07:45 PM, Patrick Palka wrote: >> >> stdarg_p() apparently returns false for a variadic function that has no >> concrete parameters, e.g. "void foo (...);". This patch fixes this >> issue by removing the predicate's seemingly bogus "n != NULL_TREE" test. > > > What does this do with K&R non-prototype declarations, e.g. "int main();"? stdarg_p (decl) now returns true when breaking on finish_decl() for "int main();". I'm not sure if that's right or not.. But never mind, I'm getting hundreds of failures from C tests that define main without a parameter list e.g. "int main () { ... }". This is an issue not worth fixing.. > > Jason >
On 04/20/2015 09:02 AM, Patrick Palka wrote: > But never mind, I'm getting hundreds of failures from C tests that > define main without a parameter list e.g. "int main () { ... }". This > is an issue not worth fixing.. Yep, that's what I was wondering. I think it makes sense to fix this testcase in the C++ front end rather than in code shared between front ends. Jason
diff --git a/gcc/testsuite/g++.dg/variadic-main.C b/gcc/testsuite/g++.dg/variadic-main.C new file mode 100644 index 0000000..b262bfd --- /dev/null +++ b/gcc/testsuite/g++.dg/variadic-main.C @@ -0,0 +1,7 @@ +/* { dg-options "-Wpedantic" } */ + +int +main (...) /* { dg-warning "declared as variadic function" } */ +{ + return 0; +} diff --git a/gcc/tree.c b/gcc/tree.c index 01860af..d388a1c 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -11518,7 +11518,7 @@ stdarg_p (const_tree fntype) n = t; } - return n != NULL_TREE && n != void_type_node; + return n != void_type_node; } /* Return true if TYPE has a prototype. */