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.
(Zero-parameter functions like "void bar (void);" will always have a void_type_node sentinel in their fntype's argument list.) OK to commit after testing? gcc/ChangeLog: * tree.c (stdarg_p): Return true for variadic functions with no concrete parameters. gcc/testsuite/ChangeLog: * g++.dg/variadic-main.C: New test. --- gcc/testsuite/g++.dg/variadic-main.C | 7 +++++++ gcc/tree.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/variadic-main.C 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. */ -- 2.4.0.rc2