From 3789b316508f81b2b12ae20b64a8a0ede9c6c86e Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 12 Oct 2004 09:32:17 +0100 Subject: [PATCH] re PR c/17301 (ICE on wrong usage of __builtin_stdarg_start) PR c/17301 * c-typeck.c (convert_arguments): Return error_mark_node if there are too few arguments. (build_function_call): Handle error_mark_node return from convert_arguments. testsuite: * gcc.dg/pr17301-2.c: New test. From-SVN: r88921 --- gcc/ChangeLog | 8 ++++++++ gcc/c-typeck.c | 11 +++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr17301-2.c | 9 +++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr17301-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5f387f82160d..1ba7210dc397 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-10-12 Joseph S. Myers + + PR c/17301 + * c-typeck.c (convert_arguments): Return error_mark_node if there + are too few arguments. + (build_function_call): Handle error_mark_node return from + convert_arguments. + 2004-10-06 Paolo Bonzini * configure.ac (symbolic_link): Replace with $LN_S. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 5fe3b9d19c77..7cc1024035e1 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1987,6 +1987,9 @@ build_function_call (tree function, tree params) coerced_params = convert_arguments (TYPE_ARG_TYPES (fntype), params, function, fundecl); + if (coerced_params == error_mark_node) + return error_mark_node; + /* Check that the arguments to the function are valid. */ check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params); @@ -2014,7 +2017,8 @@ build_function_call (tree function, tree params) /* Convert the argument expressions in the list VALUES to the types in the list TYPELIST. The result is a list of converted - argument expressions. + argument expressions, unless there are too few arguments in which + case it is error_mark_node. If TYPELIST is exhausted, or when an element has NULL as its type, perform the default conversions. @@ -2219,7 +2223,10 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl) } if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) - error ("too few arguments to function %qE", function); + { + error ("too few arguments to function %qE", function); + return error_mark_node; + } return nreverse (result); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 13217f75a5b9..766dcecec232 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-10-12 Joseph S. Myers + + PR c/17301 + * gcc.dg/pr17301-2.c: New test. + 2004-10-11 Mark Mitchell PR c++/15876 diff --git a/gcc/testsuite/gcc.dg/pr17301-2.c b/gcc/testsuite/gcc.dg/pr17301-2.c new file mode 100644 index 000000000000..e89b9538623e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr17301-2.c @@ -0,0 +1,9 @@ +/* Invalid use of __builtin_stdarg_start should not cause an ICE. Bug + 17301. Case with no arguments. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo (char *format, ...) +{ + __builtin_stdarg_start (); /* { dg-error "error: too few arguments to function '__builtin_stdarg_start'" } */ +}