Patchwork Commit: XStormy16: Fix xstormy16_init_builtins()

login
register
mail settings
Submitter Nick Clifton
Date May 22, 2011, 2:55 p.m.
Message ID <m3oc2u944z.fsf@redhat.com>
Download mbox | patch
Permalink /patch/96754/
State New
Headers show

Comments

Nick Clifton - May 22, 2011, 2:55 p.m.
Hi Guys,

  I am checking in the patch below to fix a couple of bugs in the
  xstormy16_init_builtins function.  The first was that the code was
  initialising the args[2] array element, which does not exist.  The
  second was that the arguments are constructed in the "args" array, but
  the build_function_type_list was being past bogus values from the
  "arg" array.

Cheers
  Nick

gcc/ChangeLog
2011-05-22  Nick Clifton  <nickc@redhat.com>

	* config/stormy16/stormy16.c (xstormy16_init_builtins): prevent
	initialisation of non-existent args[2] element.  Use args[] array
	not arg[] array to pass arguments to build_function_type_list.

Patch

Index: gcc/config/stormy16/stormy16.c
===================================================================
--- gcc/config/stormy16/stormy16.c	(revision 174027)
+++ gcc/config/stormy16/stormy16.c	(working copy)
@@ -2266,7 +2266,7 @@ 
 
       gcc_assert (n_args <= (int) ARRAY_SIZE (args));
 
-      for (a = n_args; a >= 0; a--)
+      for (a = n_args - 1; a >= 0; a--)
 	args[a] = NULL_TREE;
 
       for (a = n_args; a >= 0; a--)
@@ -2284,9 +2284,9 @@ 
 	  else
 	    args[a-1] = arg;
 	}
-      ftype = build_function_type_list (ret_type, arg[0], arg[1], NULL_TREE);
+      ftype = build_function_type_list (ret_type, args[0], args[1], NULL_TREE);
       add_builtin_function (s16builtins[i].name, ftype,
-			    i, BUILT_IN_MD, NULL, NULL);
+			    i, BUILT_IN_MD, NULL, NULL_TREE);
     }
 }