This is a revised patch that Peter recently submitted
<https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01571.html>, but
it was lacking a testcase and a better comment.  This patch
adds a testcase (kind of a hacky one), the comment is hopefully
better too.  Joseph already said that the code changes look ok.

Bootstrapped/regtested on x86_64-linux, ok for trunk?
Ok also for 4.9/4.8?

2014-07-14  Marek Polacek  <pola...@redhat.com>
            Manuel López-Ibáñez  <m...@gcc.gnu.org>

        PR c/57653
        * c-opts.c (c_finish_options): If -imacros is in effect, return.

        * c-c++-common/pr57653.c: New test.
        * c-c++-common/pr57653.h: New file.

diff --git gcc/c-family/c-opts.c gcc/c-family/c-opts.c
index 5ee7024..30de1e1 100644
--- gcc/c-family/c-opts.c
+++ gcc/c-family/c-opts.c
@@ -1347,6 +1347,12 @@ c_finish_options (void)
 static void
 push_command_line_include (void)
 {
+  /* This can happen if disabled by -imacros for example.
+     Punt so that we don't set "<command-line>" as the filename for
+     the header.  */
+  if (include_cursor > deferred_count)
+    return;
+
   if (!done_preinclude)
     {
       done_preinclude = true;
diff --git gcc/testsuite/c-c++-common/pr57653.c 
gcc/testsuite/c-c++-common/pr57653.c
index e69de29..620471e 100644
--- gcc/testsuite/c-c++-common/pr57653.c
+++ gcc/testsuite/c-c++-common/pr57653.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-imacros ${srcdir}/c-c++-common/pr57653.h" } */
+
+__attribute__((used)) static const char s[] = F;
+
+/* { dg-final { scan-assembler-not "command-line" } } */
diff --git gcc/testsuite/c-c++-common/pr57653.h 
gcc/testsuite/c-c++-common/pr57653.h
index e69de29..5a93388 100644
--- gcc/testsuite/c-c++-common/pr57653.h
+++ gcc/testsuite/c-c++-common/pr57653.h
@@ -0,0 +1 @@
+#define F __FILE__

        Marek

Reply via email to