This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Further patch for bug 17301
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 12 Oct 2004 08:32:25 +0000 (UTC)
- Subject: Further patch for bug 17301
This patch fixes a further case of bug 17301, where there are no
arguments at all to __builtin_stdarg_start. In this case the error
was already detected by the prototype, but an ICE followed. An
appropriate fix seems to be to ensure that if there are too few
arguments (too many poses less of a problem) then the call becomes
error_mark_node and so there is no subsequent attempt at expanding it;
the C++ front end already does something similar.
Bootstrapped with no regressions on i686-pc-linux-gnu. Applied to
mainline.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
2004-10-12 Joseph S. Myers <jsm@polyomino.org.uk>
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:
2004-10-12 Joseph S. Myers <jsm@polyomino.org.uk>
PR c/17301
* gcc.dg/pr17301-2.c: New test.
diff -rupN GCC.orig/gcc/c-typeck.c GCC/gcc/c-typeck.c
--- GCC.orig/gcc/c-typeck.c 2004-10-08 19:46:40.000000000 +0000
+++ GCC/gcc/c-typeck.c 2004-10-11 11:01:15.000000000 +0000
@@ -1987,6 +1987,9 @@ build_function_call (tree function, tree
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
/* 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 v
}
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 -rupN GCC.orig/gcc/testsuite/gcc.dg/pr17301-2.c GCC/gcc/testsuite/gcc.dg/pr17301-2.c
--- GCC.orig/gcc/testsuite/gcc.dg/pr17301-2.c 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/pr17301-2.c 2004-10-11 09:02:51.000000000 +0000
@@ -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'" } */
+}