public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix ICE in ~macro_use_before_def (PR preprocessor/83602)
@ 2018-01-02 21:08 Jakub Jelinek
  2018-01-03 12:14 ` Nathan Sidwell
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-01-02 21:08 UTC (permalink / raw)
  To: Jason Merrill, Nathan Sidwell, David Malcolm; +Cc: gcc-patches

Hi!

If lookup_name_fuzzy finds an exact match with a macro, it later in the dtor
uses node->value.macro->line in libcpp.  The problem is that for builtin
macros node->value.macro contains garbage, we use node->value.builtin union
member in those cases instead.  It doesn't make any sense to look up
location of a builtin macro definition anyway, those are very special
entities.  So, this patch just ignores those, because we can't do anything
useful with them.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-01-02  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/83602
	* name-lookup.c (lookup_name_fuzzy): Don't use macro_use_before_def
	for builtin macros.

	* g++.dg/cpp/pr83602.C: New test.

--- gcc/cp/name-lookup.c.jj	2017-12-19 18:09:05.828304241 +0100
+++ gcc/cp/name-lookup.c	2018-01-02 14:00:36.616761370 +0100
@@ -5757,7 +5757,7 @@ lookup_name_fuzzy (tree name, enum looku
       /* If we have an exact match for a macro name, then the
 	 macro has been used before it was defined.  */
       cpp_hashnode *macro = bmm.blithely_get_best_candidate ();
-      if (macro)
+      if (macro && (macro->flags & NODE_BUILTIN) == 0)
 	return name_hint (NULL,
 			  new macro_use_before_def (loc, macro));
     }
--- gcc/testsuite/g++.dg/cpp/pr83602.C.jj	2018-01-02 14:04:48.062827484 +0100
+++ gcc/testsuite/g++.dg/cpp/pr83602.C	2018-01-02 14:03:56.517813869 +0100
@@ -0,0 +1,4 @@
+// PR preprocessor/83602
+// { dg-do compile }
+
+_Pragma	// { dg-error "_Pragma" }

	Jakub

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

* Re: [C++ PATCH] Fix ICE in ~macro_use_before_def (PR preprocessor/83602)
  2018-01-02 21:08 [C++ PATCH] Fix ICE in ~macro_use_before_def (PR preprocessor/83602) Jakub Jelinek
@ 2018-01-03 12:14 ` Nathan Sidwell
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2018-01-03 12:14 UTC (permalink / raw)
  To: Jakub Jelinek, Jason Merrill, David Malcolm; +Cc: gcc-patches

On 01/02/2018 04:07 PM, Jakub Jelinek wrote:
> Hi!
> 
> If lookup_name_fuzzy finds an exact match with a macro, it later in the dtor
> uses node->value.macro->line in libcpp.  The problem is that for builtin
> macros node->value.macro contains garbage, we use node->value.builtin union
> member in those cases instead.  It doesn't make any sense to look up
> location of a builtin macro definition anyway, those are very special
> entities.  So, this patch just ignores those, because we can't do anything
> useful with them.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2018-01-02  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR preprocessor/83602
> 	* name-lookup.c (lookup_name_fuzzy): Don't use macro_use_before_def
> 	for builtin macros.
> 
> 	* g++.dg/cpp/pr83602.C: New test.

ok


-- 
Nathan Sidwell

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

end of thread, other threads:[~2018-01-03 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-02 21:08 [C++ PATCH] Fix ICE in ~macro_use_before_def (PR preprocessor/83602) Jakub Jelinek
2018-01-03 12:14 ` Nathan Sidwell

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