Patchwork Fix Ada bootstrap (canonical -I option form)

login
register
mail settings
Submitter Joseph S. Myers
Date Sept. 3, 2010, 1:01 p.m.
Message ID <Pine.LNX.4.64.1009031301070.26960@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/63679/
State New
Headers show

Comments

Joseph S. Myers - Sept. 3, 2010, 1:01 p.m.
This patch fixes an Ada bootstrap issue caused by my options aliases
changes.  When gnat1 reconstitutes an argv array, it needs to generate
-I options in joined form for the sake of Ada-language code requiring
that form, and it is now possible for (ignored) options to have empty
canonical form (although this should only arise if gnat1 is called
directly with such an option or specs somehow generate such an
option).

Tested on i686-pc-linux-gnu to fix Ada-enabled bootstrap.  OK to
commit?

2010-09-03  Joseph Myers  <joseph@codesourcery.com>

	PR ada/45499
	* gcc-interface/misc.c (gnat_init_options): Allow options with
	empty canonical form.  Generate a single save_argv element from -I
	options.
Arnaud Charlet - Sept. 3, 2010, 1:07 p.m.
> This patch fixes an Ada bootstrap issue caused by my options aliases
> changes.  When gnat1 reconstitutes an argv array, it needs to generate
> -I options in joined form for the sake of Ada-language code requiring
> that form, and it is now possible for (ignored) options to have empty
> canonical form (although this should only arise if gnat1 is called
> directly with such an option or specs somehow generate such an
> option).
> 
> Tested on i686-pc-linux-gnu to fix Ada-enabled bootstrap.  OK to
> commit?

OK, thanks.

Patch

Index: gcc/ada/gcc-interface/misc.c
===================================================================
--- gcc/ada/gcc-interface/misc.c	(revision 163785)
+++ gcc/ada/gcc-interface/misc.c	(working copy)
@@ -273,13 +273,24 @@  gnat_init_options (unsigned int decoded_
   for (i = 0; i < decoded_options_count; i++)
     {
       if (decoded_options[i].errors
-	  || decoded_options[i].opt_index == OPT_SPECIAL_unknown)
+	  || decoded_options[i].opt_index == OPT_SPECIAL_unknown
+	  || decoded_options[i].canonical_option_num_elements == 0)
 	continue;
-      gcc_assert (decoded_options[i].canonical_option_num_elements >= 1
-		  && decoded_options[i].canonical_option_num_elements <= 2);
-      save_argv[save_argc++] = decoded_options[i].canonical_option[0];
-      if (decoded_options[i].canonical_option_num_elements >= 2)
-	save_argv[save_argc++] = decoded_options[i].canonical_option[1];
+      if (decoded_options[i].opt_index == OPT_I)
+	{
+	  gcc_assert (decoded_options[i].canonical_option_num_elements == 2);
+	  save_argv[save_argc++]
+	    = concat (decoded_options[i].canonical_option[0],
+		      decoded_options[i].canonical_option[1], NULL);
+	}
+      else
+	{
+	  gcc_assert (decoded_options[i].canonical_option_num_elements >= 1
+		      && decoded_options[i].canonical_option_num_elements <= 2);
+	  save_argv[save_argc++] = decoded_options[i].canonical_option[0];
+	  if (decoded_options[i].canonical_option_num_elements >= 2)
+	    save_argv[save_argc++] = decoded_options[i].canonical_option[1];
+	}
     }
   save_argv[save_argc] = NULL;