]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* opts-common.c (decode_cmdline_option): Print empty string
authorjiez <jiez@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Feb 2011 02:04:43 +0000 (02:04 +0000)
committerjiez <jiez@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Feb 2011 02:04:43 +0000 (02:04 +0000)
argument as "" in decoded->orig_option_with_args_text.
* gcc.c (execute): Print empty string argument as ""
in the verbose output.
(do_spec_1): Keep empty string argument.

testsuite/
* gcc.dg/cpp/include7.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170426 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gcc.c
gcc/opts-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/include7.c [new file with mode: 0644]

index 12d3137b3d16fd6d6a2eab3961caa075112678bb..aaa703d28cd71ad44d9579dda382ff77ac1aa071 100644 (file)
@@ -1,3 +1,11 @@
+2011-02-23  Jie Zhang  <jie@codesourcery.com>
+
+       * opts-common.c (decode_cmdline_option): Print empty string
+       argument as "" in decoded->orig_option_with_args_text.
+       * gcc.c (execute): Print empty string argument as ""
+       in the verbose output.
+       (do_spec_1): Keep empty string argument.
+
 2011-02-23  Nathan Froyd  <froydnj@codesourcery.com>
 
        * config.gcc: Declare score-* and crx-* obsolete.
index 6a26aafc3cab8f60f1ab15bf971a8dae8117935d..75f522e1db5180b770887467af42ad5799803dbd 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -2538,13 +2538,20 @@ execute (void)
                        }
                      fputc ('"', stderr);
                    }
+                 /* If it's empty, print "".  */
+                 else if (!**j)
+                   fprintf (stderr, " \"\"");
                  else
                    fprintf (stderr, " %s", *j);
                }
            }
          else
            for (j = commands[i].argv; *j; j++)
-             fprintf (stderr, " %s", *j);
+             /* If it's empty, print "".  */
+             if (!**j)
+               fprintf (stderr, " \"\"");
+             else
+               fprintf (stderr, " %s", *j);
 
          /* Print a pipe symbol after all but the last command.  */
          if (i + 1 != n_commands)
@@ -4423,6 +4430,10 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
   int i;
   int value;
 
+  /* If it's an empty string argument to a switch, keep it as is.  */
+  if (inswitch && !*p)
+    arg_going = 1;
+
   while ((c = *p++))
     /* If substituting a switch, treat all chars like letters.
        Otherwise, NL, SPC, TAB and % are special.  */
@@ -5149,7 +5160,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
          case '*':
            if (soft_matched_part)
              {
-               do_spec_1 (soft_matched_part, 1, NULL);
+               if (soft_matched_part[0])
+                 do_spec_1 (soft_matched_part, 1, NULL);
                do_spec_1 (" ", 0, NULL);
              }
            else
index 3c4044a206377a26c75d58d963e7bcaa2a3136e9..f958b7ed95355dc6dcb03fe3045df9ac3cc40138 100644 (file)
@@ -607,11 +607,15 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
     {
       if (i < result)
        {
+         size_t len;
          if (opt_index == OPT_SPECIAL_unknown)
            decoded->canonical_option[i] = argv[i];
          else
            decoded->canonical_option[i] = NULL;
-         total_len += strlen (argv[i]) + 1;
+         len = strlen (argv[i]);
+         /* If the argument is an empty string, we will print it as "" in
+            orig_option_with_args_text.  */
+         total_len += (len != 0 ? len : 2) + 1;
        }
       else
        decoded->canonical_option[i] = NULL;
@@ -637,7 +641,14 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
     {
       size_t len = strlen (argv[i]);
 
-      memcpy (p, argv[i], len);
+      /* Print the empty string verbally.  */
+      if (len == 0)
+       {
+         *p++ = '"';
+         *p++ = '"';
+       }
+      else
+       memcpy (p, argv[i], len);
       p += len;
       if (i == result - 1)
        *p++ = 0;
index f64735eb17a6afd958092295b9156447e70d8643..60e924bcf3986781b463f3b7036659b0fd444322 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-23  Jie Zhang  <jie@codesourcery.com>
+
+       * gcc.dg/cpp/include7.c: New test.
+
 2011-02-22  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/47242
diff --git a/gcc/testsuite/gcc.dg/cpp/include7.c b/gcc/testsuite/gcc.dg/cpp/include7.c
new file mode 100644 (file)
index 0000000..0e95601
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-I \"\"" } */
+