]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/ada/misc.c
Merge basic-improvements-branch to trunk
[thirdparty/gcc.git] / gcc / ada / misc.c
index ad4310663437374ea62ce06ff22bcebd76649e3b..a8293e709fb5e85270edc6e4b7f5ffbd84c888e6 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "tree.h"
 #include "rtl.h"
 #include "errors.h"
@@ -207,8 +209,8 @@ gnat_parse_file (set_yydebug)
 
 /* Decode all the language specific options that cannot be decoded by GCC.
    The option decoding phase of GCC calls this routine on the flags that
-   it cannot decode. This routine returns 1 if it is successful, otherwise
-   it returns 0. */
+   it cannot decode.  This routine returns the number of consecutive arguments
+   from ARGV that it successfully decoded; 0 indicates failure.  */
 
 static int
 gnat_decode_option (argc, argv)
@@ -220,10 +222,28 @@ gnat_decode_option (argc, argv)
 
   if (!strncmp (p, "-I", 2))
     {
-      /* Pass the -I switches as-is. */
-      gnat_argv[gnat_argc] = p;
-      gnat_argc ++;
-      return 1;
+      /* We might get -I foo or -Ifoo.  Canonicalize to the latter.  */
+      if (p[2] == '\0')
+       {
+         char *q;
+
+         if (argv[1] == 0)
+           return 0;
+
+         q = xmalloc (sizeof("-I") + strlen (argv[1]));
+         strcpy (q, "-I");
+         strcat (q, argv[1]);
+
+         gnat_argv[gnat_argc] = q;
+         gnat_argc ++;
+         return 2;  /* consumed argument */
+       }
+      else
+       {
+         gnat_argv[gnat_argc] = p;
+         gnat_argc ++;
+         return 1;
+       }
     }
 
   else if (!strncmp (p, "-gant", 5))