Fixed error in build_gcc_call().
authorJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 16 Apr 2010 01:37:25 +0000 (21:37 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 16 Apr 2010 01:37:25 +0000 (21:37 -0400)
Building the argtype_list the wrong way resulted in a malformed list
that caused build_function_type() to crash in some circumstances.

src/aop-weave.c

index 550a5d4892c60677dbf710deef45cc116ad325bb..831502dd8fd05252f08e80a3d2db2385bd1547c3 100644 (file)
@@ -89,7 +89,7 @@ build_gcc_call (const char *func_name, tree return_type, va_list argp)
   gimple func_call;
 
   arg_list = VEC_alloc (tree, heap, 2);
-  argtype_list = void_list_node;
+  argtype_list = NULL_TREE;
 
   while ((kind = va_arg (argp, enum aop_argkind)) != AOP_TERM_ARG)
     {
@@ -119,6 +119,11 @@ build_gcc_call (const char *func_name, tree return_type, va_list argp)
   /* Using tree_cons builds the list backwards!  Un-backwards it. */
   argtype_list = nreverse (argtype_list);
 
+  /* The last element of an argument list should always be
+     void_list_node, to signify that it is not a varargs argument
+     list. */
+  argtype_list = chainon (argtype_list, void_list_node);
+
   func_type = build_function_type (return_type, argtype_list);
   func_decl = build_fn_decl (func_name, func_type);
   func_call = gimple_build_call_vec (func_decl, arg_list);