[C++] set_global_binding tweak

Message ID 62193b2d-a4df-5ca9-95dd-16f238aa4a92@acm.org
State New
Headers show
Series
  • [C++] set_global_binding tweak
Related show

Commit Message

Nathan Sidwell Oct. 10, 2017, 2:47 p.m.
It turns out that we no longer have to worry about the stat hack when 
pushing internal decls into the global namespace.  I think it was last 
week's change to record_builtin_type, which did have the habit of 
pushing duplicates before that.

Applying to trunk.

nathan

Patch

2017-10-10  Nathan Sidwell  <nathan@acm.org>

	* name-lookup.c (set_global_binding): Don't deal with STAT_HACK.

Index: name-lookup.c
===================================================================
--- name-lookup.c	(revision 253502)
+++ name-lookup.c	(working copy)
@@ -4858,22 +4858,13 @@  set_global_binding (tree decl)
   bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
 
   tree *slot = find_namespace_slot (global_namespace, DECL_NAME (decl), true);
-  tree old = MAYBE_STAT_DECL (*slot);
 
-  if (!old)
-    *slot = decl;
-  else if (old == decl)
-    ;
-  else if (!STAT_HACK_P (*slot)
-	   && TREE_CODE (decl) == TYPE_DECL && DECL_ARTIFICIAL (decl))
-    *slot = stat_hack (old, decl);
-  else if (!STAT_HACK_P (*slot)
-	   && TREE_CODE (old) == TYPE_DECL && DECL_ARTIFICIAL (old))
-    *slot = stat_hack (decl, old);
-  else
-    /* The user's placed something in the implementor's
-       namespace.  */
-    diagnose_name_conflict (decl, old);
+  if (*slot)
+    /* The user's placed something in the implementor's namespace.  */
+    diagnose_name_conflict (decl, MAYBE_STAT_DECL (*slot));
+
+  /* Force the binding, so compiler internals continue to work.  */
+  *slot = decl;
 
   timevar_cond_stop (TV_NAME_LOOKUP, subtime);
 }