Patchwork [Ada] Fix error detection for -I

login
register
mail settings
Submitter Eric Botcazou
Date Feb. 14, 2011, 7:14 p.m.
Message ID <201102142014.00673.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/83152/
State New
Headers show

Comments

Eric Botcazou - Feb. 14, 2011, 7:14 p.m.
This is a regression present on the mainline.  The Ada compiler fails to 
diagnose a missing argument for -I when there is a -gnat switch next.

Fixed thusly, tested on i586-suse-linux, applied on the mainline.


2011-02-14  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/misc.c (gnat_init_options): Do not concatenate -I and
	its argument, except for the special -I- switch.


2011-02-14  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/include.adb: New test.

Patch

Index: gcc-interface/misc.c
===================================================================
--- gcc-interface/misc.c	(revision 169914)
+++ gcc-interface/misc.c	(working copy)
@@ -195,13 +195,12 @@  gnat_init_options (unsigned int decoded_
 	  || num_elements == 0)
 	continue;
 
-      if (decoded_options[i].opt_index == OPT_I)
-	{
-	  gcc_assert (num_elements == 2);
-	  save_argv[save_argc++]
-	    = concat (decoded_options[i].canonical_option[0],
-		      decoded_options[i].canonical_option[1], NULL);
-	}
+      /* Deal with -I- specially since it must be a single switch.  */
+      if (decoded_options[i].opt_index == OPT_I
+	  && num_elements == 2
+	  && decoded_options[i].canonical_option[1][0] == '-'
+	  && decoded_options[i].canonical_option[1][1] == '\0')
+	save_argv[save_argc++] = "-I-";
       else
 	{
 	  gcc_assert (num_elements >= 1 && num_elements <= 2);