[PATCH, libcpp] Dependency generation (-M) does not quote '#' in filenames

Markus Milleder markus.milleder@generali.at
Tue Mar 4 14:04:00 GMT 2008



This is a trivial patch for PR preprocessor/35458 (which I have just opened, and where I have attached the patch)

This is actually a ping of http://gcc.gnu.org/ml/gcc-patches/2007-04/msg00134.html, but now with a testcase

While I do not have a copyright assignment with the FSF; I blieve this patch is small and simple enough to be well below the limit.

Tested make check-gcc "RUNTESTFLAGS=cpp.exp" on i686-pc-cygwin with the snapshot from 20080215 , where the test fails without and passes with the patch.

OK for trunk ?

      Markus Milleder


2008-03-04  Markus Milleder
      PR preprocessor/35458
      libcpp/
            * mkdeps.c (munge): Quote '#' with a '\'.

      gcc/testsuite/
            * cmdlne-M-2.c, #cmdlne-M-2.h, cmdlne-M-2#.h: New.


diff -urpN orig/gcc/testsuite/gcc.dg/cpp/#cmdlne-M-2.h patched/gcc/testsuite/gcc.dg/cpp/#cmdlne-M-2.h
--- orig/gcc/testsuite/gcc.dg/cpp/#cmdlne-M-2.h 1970-01-01 01:00:00.000000000 +0100
+++ patched/gcc/testsuite/gcc.dg/cpp/#cmdlne-M-2.h    2008-03-03 22:40:38.000000000 +0100
@@ -0,0 +1 @@
+
diff -urpN orig/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2#.h patched/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2#.h
--- orig/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2#.h 1970-01-01 01:00:00.000000000 +0100
+++ patched/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2#.h    2008-03-03 22:40:36.000000000 +0100
@@ -0,0 +1 @@
+
diff -urpN orig/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2.c patched/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2.c
--- orig/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2.c  1970-01-01 01:00:00.000000000 +0100
+++ patched/gcc/testsuite/gcc.dg/cpp/cmdlne-M-2.c     2008-03-03 22:26:50.000000000 +0100
@@ -0,0 +1,14 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+/* { dg-options "-M" } */
+
+/* Test that dependency output suppresses warnings by implying -w.  */
+
+#include "#cmdlne-M-2.h"
+#include "cmdlne-M-2#.h"
+
+/* { dg-final { scan-file cmdlne-M-2.i "(^|\\n)cmdlne-M-2.o:" } }
+   { dg-final { scan-file cmdlne-M-2.i "cmdlne-M-2.c" } }
+   { dg-final { scan-file cmdlne-M-2.i "\\\\#cmdlne-M-2.h" } }
+   { dg-final { scan-file cmdlne-M-2.i "cmdlne-M-2\\\\#.h" } } */
diff -urpN orig/libcpp/mkdeps.c patched/libcpp/mkdeps.c
--- orig/libcpp/mkdeps.c      2007-01-30 16:50:00.000000000 +0100
+++ patched/libcpp/mkdeps.c   2008-03-03 22:30:52.000000000 +0100
@@ -79,6 +79,11 @@ munge (const char *filename)
        /* '$' is quoted by doubling it.  */
        len++;
        break;
+
+     case '#':
+       /* '#' is quoted with a backslash.  */
+       len++;
+       break;
      }
     }

@@ -100,6 +105,10 @@ munge (const char *filename)
        *dst++ = '$';
        break;

+     case '#':
+       *dst++ = '\\';
+       break;
+
      default:
        /* nothing */;
      }




More information about the Gcc-patches mailing list