This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for bug 17301


This patch fixes bug 17301, an ICE because of a missing check for too
few arguments to __builtin_va_start.

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

-- 
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-10  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/17301
	* builtins.c (expand_builtin_va_start): Check for too few
	arguments to va_start.

testsuite:
2004-10-10  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/17301
	* gcc.dg/pr17301-1.c: New test.

diff -rupN GCC.orig/gcc/builtins.c GCC/gcc/builtins.c
--- GCC.orig/gcc/builtins.c	2004-10-08 20:20:19.000000000 +0000
+++ GCC/gcc/builtins.c	2004-10-09 18:40:28.000000000 +0000
@@ -3861,6 +3861,11 @@ expand_builtin_va_start (tree arglist)
 
   chain = TREE_CHAIN (arglist);
 
+  if (!chain)
+    {
+      error ("too few arguments to function %<va_start%>");
+      return const0_rtx;
+    }
   if (TREE_CHAIN (chain))
     error ("too many arguments to function %<va_start%>");
 
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/pr17301-1.c GCC/gcc/testsuite/gcc.dg/pr17301-1.c
--- GCC.orig/gcc/testsuite/gcc.dg/pr17301-1.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/pr17301-1.c	2004-10-09 18:40:45.000000000 +0000
@@ -0,0 +1,11 @@
+/* Invalid use of __builtin_stdarg_start should not cause an ICE.  Bug
+   17301.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int
+write_format (char *format, ...)
+{
+  __builtin_va_list p;
+  __builtin_stdarg_start (p); /* { dg-error "error: too few arguments to function 'va_start'" } */
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]