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  <ja...@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

Reply via email to