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

* Re: [PATCH] Fix -imacros (PR c/57653)
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2014-07-18  5:06 UTC (permalink / raw)
  To: Marek Polacek, GCC Patches, Joseph S. Myers

On 07/15/14 02:18, Marek Polacek wrote:
> 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.
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 ;-)


Jeff

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

* Re: [PATCH] Fix -imacros (PR c/57653)
  2014-07-18  5:06 ` Jeff Law
@ 2014-07-23 17:53   ` Marek Polacek
  2014-07-25 21:18     ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Polacek @ 2014-07-23 17:53 UTC (permalink / raw)
  To: Jeff Law; +Cc: GCC Patches, Joseph S. Myers

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

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

* Re: [PATCH] Fix -imacros (PR c/57653)
  2014-07-23 17:53   ` Marek Polacek
@ 2014-07-25 21:18     ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2014-07-25 21:18 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches, Joseph S. Myers

On 07/23/14 11:49, Marek Polacek wrote:
> 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.
Perfect.  Thanks for picking up the ball on this one.


Jeff

^ 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).