public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix -imacros (PR c/57653)
@ 2014-07-15  8:20 Marek Polacek
  2014-07-18  5:06 ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Polacek @ 2014-07-15  8:20 UTC (permalink / raw)
  To: GCC Patches, Joseph S. Myers, Jeff Law

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  <polacek@redhat.com>
	    Manuel López-Ibáñez  <manu@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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-25 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15  8:20 [PATCH] Fix -imacros (PR c/57653) Marek Polacek
2014-07-18  5:06 ` Jeff Law
2014-07-23 17:53   ` Marek Polacek
2014-07-25 21:18     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).