This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix -imacros (PR c/57653)


On Thu, Jul 17, 2014 at 02:40:27AM -0600, Jeff Law wrote:
> I was really hoping someone could add tests from the old (2004?) thread
> between DJ and Per to ensure we weren't regressing any of those cases while
> fixing 57653.  In fact, I think I'd pre-approved with those tests added ;-)

All I could find was a test (mentioned twice by DJ) that was crashing with
-imacros and an empty .h and .c file.  I added it in the following.
I'm keeping the test I already had in the previous patch, because it
tests something that is fixed with this patch.

Bootstrapped/regtested on x86_64-linux, applying to trunk.

2014-07-23  Marek Polacek  <polacek@redhat.com>

	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.
	* c-c++-common/pr57653-2.c: New test.
	* c-c++-common/pr57653-2.h: New file.

diff --git gcc/c-family/c-opts.c gcc/c-family/c-opts.c
index 968b703..3f8e6e6 100644
--- gcc/c-family/c-opts.c
+++ gcc/c-family/c-opts.c
@@ -1438,6 +1438,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-2.c gcc/testsuite/c-c++-common/pr57653-2.c
index e69de29..086f6be 100644
--- gcc/testsuite/c-c++-common/pr57653-2.c
+++ gcc/testsuite/c-c++-common/pr57653-2.c
@@ -0,0 +1,4 @@
+/* { dg-do preprocess } */
+/* { dg-options "-imacros ${srcdir}/c-c++-common/pr57653-2.h" } */
+
+/* Empty.  */
diff --git gcc/testsuite/c-c++-common/pr57653-2.h gcc/testsuite/c-c++-common/pr57653-2.h
index e69de29..8b13789 100644
--- gcc/testsuite/c-c++-common/pr57653-2.h
+++ gcc/testsuite/c-c++-common/pr57653-2.h
@@ -0,0 +1 @@
+
diff --git gcc/testsuite/c-c++-common/pr57653-3.c gcc/testsuite/c-c++-common/pr57653-3.c
deleted file mode 100644
index e69de29..0000000
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]