re PR driver/36312 (should refuse to overwrite input file with output file)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 19 Nov 2014 18:11:54 +0000 (18:11 +0000)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 19 Nov 2014 18:11:54 +0000 (19:11 +0100)
PR driver/36312
PR driver/63837
* gcc.c (process_command): Don't check for input/output
filename equality if output is HOST_BIT_BUCKET.
* toplev.c (init_asm_output): Likewise.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r217789

gcc/ChangeLog
gcc/gcc.c
gcc/toplev.c

index 791599f..15010a0 100644 (file)
@@ -1,3 +1,12 @@
+2014-11-19  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR driver/36312
+       PR driver/63837
+       * gcc.c (process_command): Don't check for input/output
+       filename equality if output is HOST_BIT_BUCKET.
+       * toplev.c (init_asm_output): Likewise.
+
 2014-11-19  David Malcolm  <dmalcolm@redhat.com>
 
        Merger of git branch "gimple-classes-v2-option-3".
index 653ca8d..c6d1baf 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4155,7 +4155,9 @@ process_command (unsigned int decoded_options_count,
                           CL_DRIVER, &handlers, global_dc);
     }
 
-  if (output_file && strcmp (output_file, "-"))
+  if (output_file
+      && strcmp (output_file, "-") != 0
+      && strcmp (output_file, HOST_BIT_BUCKET) != 0)
     {
       int i;
       for (i = 0; i < n_infiles; i++)
index 2e48047..86c4b81 100644 (file)
@@ -945,7 +945,8 @@ init_asm_output (const char *name)
        }
       if (!strcmp (asm_file_name, "-"))
        asm_out_file = stdout;
-      else if (!canonical_filename_eq (asm_file_name, name))
+      else if (!canonical_filename_eq (asm_file_name, name)
+              || !strcmp (asm_file_name, HOST_BIT_BUCKET))
        asm_out_file = fopen (asm_file_name, "w");
       else
        /* Use fatal_error (UNKOWN_LOCATION) instead of just fatal_error to