public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-3634] c++: Kill DECL_ANTICIPATED
@ 2020-10-02 19:26 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-10-02 19:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:679dbc9dcec0d1240951442947199ba155f494b6

commit r11-3634-g679dbc9dcec0d1240951442947199ba155f494b6
Author: Nathan Sidwell <nathan@acm.org>
Date:   Fri Oct 2 12:21:08 2020 -0700

    c++: Kill DECL_ANTICIPATED
    
    Here's the patch to remove DECL_ANTICIPATED, and with it hiddenness is
    managed entirely in the symbol table.  Sadly I couldn't get rid of the
    actual field without more investigation -- it's repurposed for
    OMP_PRIVATIZED_MEMBER.  It looks like a the VAR-related flags in
    lang_decl_base are not completely orthogonal, so perhaps some can be
    turned into an enumeration or something.  But that's more than I want
    to do right now.
    
    DECL_FRIEND_P Is still slightly suspect as it appears to mean more
    than just in-class definition.  However, I'm leaving that for now.
    
            gcc/cp/
            * cp-tree.h (lang_decl_base): anticipated_p is not used for
            anticipatedness.
            (DECL_ANTICIPATED): Delete.
            * decl.c (duplicate_decls): Delete DECL_ANTICIPATED_management,
            use was_hidden.
            (cxx_builtin_function): Drop DECL_ANTICIPATED setting.
            (xref_tag_1): Drop DECL_ANTICIPATED assert.
            * name-lookup.c (name_lookup::adl_class_only): Drop
            DECL_ANTICIPATED check.
            (name_lookup::search_adl): Always dedup.
            (anticipated_builtin_p): Reimplement.
            (do_pushdecl): Drop DECL_ANTICIPATED asserts & update.
            (lookup_elaborated_type_1): Drop DECL_ANTICIPATED update.
            (do_pushtag): Drop DECL_ANTICIPATED setting.
            * pt.c (push_template_decl): Likewise.
            (tsubst_friend_class): Likewise.
            libcc1/
            * libcp1plugin.cc (libcp1plugin.cc): Drop DECL_ANTICIPATED test.

Diff:
---
 gcc/cp/cp-tree.h       | 13 ++++---------
 gcc/cp/decl.c          | 31 ++++++++-----------------------
 gcc/cp/name-lookup.c   | 49 ++++++++-----------------------------------------
 gcc/cp/pt.c            | 10 +---------
 libcc1/libcp1plugin.cc |  1 -
 5 files changed, 21 insertions(+), 83 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 43e0c18ec03..c9ad75117ad 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2657,8 +2657,10 @@ struct GTY(()) lang_decl_base {
   unsigned not_really_extern : 1;	   /* var or fn */
   unsigned initialized_in_class : 1;	   /* var or fn */
   unsigned threadprivate_or_deleted_p : 1; /* var or fn */
-  unsigned anticipated_p : 1;		   /* fn, type or template */
-  /* anticipated_p reused as DECL_OMP_PRIVATIZED_MEMBER in var */
+  /* anticipated_p is no longer used for anticipated_decls (fn, type
+     or template).  It is used as DECL_OMP_PRIVATIZED_MEMBER in
+     var.  */
+  unsigned anticipated_p : 1;
   unsigned friend_or_tls : 1;		   /* var, fn, type or template */
   unsigned unknown_bound_p : 1;		   /* var */
   unsigned odr_used : 1;		   /* var or fn */
@@ -4037,13 +4039,6 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #define DECL_BUILTIN_P(NODE) \
   (DECL_SOURCE_LOCATION(NODE) == BUILTINS_LOCATION)
 
-/* Nonzero if NODE is a DECL which we know about but which has not
-   been explicitly declared, such as a built-in function or a friend
-   declared inside a class.  */
-#define DECL_ANTICIPATED(NODE) \
-  (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \
-   ->u.base.anticipated_p)
-
 /* True for artificial decls added for OpenMP privatized non-static
    data members.  */
 #define DECL_OMP_PRIVATIZED_MEMBER(NODE) \
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6b306ee4667..f333a36b0e1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1444,7 +1444,7 @@ tree
 duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
 {
   unsigned olddecl_uid = DECL_UID (olddecl);
-  int olddecl_friend = 0, types_match = 0, hidden_friend = 0;
+  int olddecl_friend = 0, types_match = 0;
   int olddecl_hidden_friend = 0;
   int new_defines_function = 0;
   tree new_template_info;
@@ -1473,7 +1473,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
 	{
 	  /* Avoid warnings redeclaring built-ins which have not been
 	     explicitly declared.  */
-	  if (DECL_ANTICIPATED (olddecl))
+	  if (was_hidden)
 	    {
 	      if (TREE_PUBLIC (newdecl)
 		  && CP_DECL_CONTEXT (newdecl) == global_namespace)
@@ -1645,7 +1645,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
       /* If a function is explicitly declared "throw ()", propagate that to
 	 the corresponding builtin.  */
       if (DECL_BUILT_IN_CLASS (olddecl) == BUILT_IN_NORMAL
-	  && DECL_ANTICIPATED (olddecl)
+	  && was_hidden
 	  && TREE_NOTHROW (newdecl)
 	  && !TREE_NOTHROW (olddecl))
 	{
@@ -2139,9 +2139,6 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
     {
       olddecl_friend = DECL_FRIEND_P (STRIP_TEMPLATE (olddecl));
       olddecl_hidden_friend = olddecl_friend && was_hidden;
-      hidden_friend = olddecl_hidden_friend && hiding;
-      if (!hidden_friend)
-	DECL_ANTICIPATED (olddecl) = false;
     }
 
   if (TREE_CODE (newdecl) == TEMPLATE_DECL)
@@ -2890,8 +2887,6 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
   DECL_UID (olddecl) = olddecl_uid;
   if (olddecl_friend)
     DECL_FRIEND_P (olddecl) = true;
-  if (hidden_friend)
-    DECL_ANTICIPATED (olddecl) = true;
 
   /* NEWDECL contains the merged attribute lists.
      Update OLDDECL to be the same.  */
@@ -4690,21 +4685,15 @@ cxx_builtin_function (tree decl)
   const char *name = IDENTIFIER_POINTER (id);
   bool hiding = false;
   if (name[0] != '_' || name[1] != '_')
-    {
-      /* In the user's namespace, it must be declared before use.  */
-      DECL_ANTICIPATED (decl) = 1;
-      hiding = true;
-    }
+    /* In the user's namespace, it must be declared before use.  */
+    hiding = true;
   else if (IDENTIFIER_LENGTH (id) > strlen ("___chk")
 	   && 0 != strncmp (name + 2, "builtin_", strlen ("builtin_"))
 	   && 0 == memcmp (name + IDENTIFIER_LENGTH (id) - strlen ("_chk"),
 			   "_chk", strlen ("_chk") + 1))
-    {
-      /* Treat __*_chk fortification functions as anticipated as well,
-	 unless they are __builtin_*_chk.  */
-      DECL_ANTICIPATED (decl) = 1;
-      hiding = true;
-    }
+    /* Treat __*_chk fortification functions as anticipated as well,
+       unless they are __builtin_*_chk.  */
+    hiding = true;
 
   /* All builtins that don't begin with an '_' should additionally
      go in the 'std' namespace.  */
@@ -15063,10 +15052,6 @@ xref_tag_1 (enum tag_types tag_code, tree name,
 	  inform (location_of (t), "previous declaration %qD", t);
 	  return error_mark_node;
 	}
-
-      gcc_checking_assert (how == TAG_how::HIDDEN_FRIEND
-			   || !(DECL_LANG_SPECIFIC (TYPE_NAME (t))
-				&& DECL_ANTICIPATED (TYPE_NAME (t))));
     }
 
   return t;
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 4024ceaa74b..190b56bf4dd 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -842,12 +842,6 @@ name_lookup::adl_class_only (tree type)
 	  if (CP_DECL_CONTEXT (fn) != context)
 	    continue;
 
-	  /* Only interested in anticipated friends.  (Non-anticipated
-	     ones will have been inserted during the namespace
-	     adl.)  */
-	  if (!DECL_ANTICIPATED (fn))
-	    continue;
-
 	  /* Template specializations are never found by name lookup.
 	     (Templates themselves can be found, but not template
 	     specializations.)  */
@@ -1079,11 +1073,8 @@ name_lookup::adl_template_arg (tree arg)
 tree
 name_lookup::search_adl (tree fns, vec<tree, va_gc> *args)
 {
-  if (fns)
-    {
-      deduping = true;
-      lookup_mark (fns, true);
-    }
+  deduping = true;
+  lookup_mark (fns, true);
   value = fns;
 
   unsigned ix;
@@ -2136,19 +2127,9 @@ strip_using_decl (tree decl)
 static bool
 anticipated_builtin_p (tree ovl)
 {
-  if (TREE_CODE (ovl) != OVERLOAD)
-    return false;
-
-  if (!OVL_HIDDEN_P (ovl))
-    return false;
-
-  tree fn = OVL_FUNCTION (ovl);
-  gcc_checking_assert (DECL_ANTICIPATED (fn));
-
-  if (DECL_BUILTIN_P (fn))
-    return true;
-
-  return false;
+  return (TREE_CODE (ovl) == OVERLOAD
+	  && OVL_HIDDEN_P (ovl)
+	  && DECL_BUILTIN_P (OVL_FUNCTION (ovl)));
 }
 
 /* BINDING records an existing declaration for a name in the current scope.
@@ -3079,14 +3060,6 @@ do_pushdecl (tree decl, bool hiding)
       tree *slot = NULL; /* Binding slot in namespace.  */
       tree old = NULL_TREE;
 
-      if (!hiding)
-	/* We should never unknownly push an anticipated decl.  */
-	gcc_checking_assert (!((TREE_CODE (decl) == TYPE_DECL
-				|| TREE_CODE (decl) == FUNCTION_DECL
-				|| TREE_CODE (decl) == TEMPLATE_DECL)
-			       && DECL_LANG_SPECIFIC (decl)
-			       && DECL_ANTICIPATED (decl)));
-
       if (level->kind == sk_namespace)
 	{
 	  /* We look in the decl's namespace for an existing
@@ -3171,8 +3144,6 @@ do_pushdecl (tree decl, bool hiding)
 		  /* Don't attempt to push it.  */
 		  return error_mark_node;
 		}
-	      /* Hide it from ordinary lookup.  */
-	      DECL_ANTICIPATED (decl) = true;
 	    }
 	}
 
@@ -6730,7 +6701,6 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
 		HIDDEN_TYPE_BINDING_P (iter) = false;
 
 		/* Unanticipate the decl itself.  */
-		DECL_ANTICIPATED (found) = false;
 		DECL_FRIEND_P (found) = false;
 
 		gcc_checking_assert (TREE_CODE (found) != TEMPLATE_DECL);
@@ -6738,7 +6708,6 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
 		if (tree ti = TYPE_TEMPLATE_INFO (TREE_TYPE (found)))
 		  {
 		    tree tmpl = TI_TEMPLATE (ti);
-		    DECL_ANTICIPATED (tmpl) = false;
 		    DECL_FRIEND_P (tmpl) = false;
 		  }
 	      }
@@ -6799,18 +6768,17 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
 	  if (reveal)
 	    {
 	      /* Reveal the previously hidden thing.  */
-	      DECL_ANTICIPATED (found) = false;
 	      DECL_FRIEND_P (found) = false;
 
 	      if (TREE_CODE (found) == TEMPLATE_DECL)
 		{
-		  DECL_ANTICIPATED (DECL_TEMPLATE_RESULT (found)) = false;
-		  DECL_FRIEND_P (DECL_TEMPLATE_RESULT (found)) = false;
+		  tree res = DECL_TEMPLATE_RESULT (found);
+		  if (DECL_LANG_SPECIFIC (res))
+		    DECL_FRIEND_P (res) = false;
 		}
 	      else if (tree ti = TYPE_TEMPLATE_INFO (TREE_TYPE (found)))
 		{
 		  tree tmpl = TI_TEMPLATE (ti);
-		  DECL_ANTICIPATED (tmpl) = false;
 		  DECL_FRIEND_P (tmpl) = false;
 		}
 	    }
@@ -7019,7 +6987,6 @@ do_pushtag (tree name, tree type, TAG_how how)
 	     ordinary name lookup.  Its corresponding TEMPLATE_DECL
 	     will be marked in push_template_decl.  */
 	  retrofit_lang_decl (tdef);
-	  DECL_ANTICIPATED (tdef) = 1;
 	  DECL_FRIEND_P (tdef) = 1;
 	}
 
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 72efecff37f..1ab5435b359 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6024,10 +6024,7 @@ push_template_decl (tree decl, bool is_friend)
 	{
 	  /* Hide template friend classes that haven't been declared yet.  */
 	  if (is_friend && TREE_CODE (decl) == TYPE_DECL)
-	    {
-	      DECL_ANTICIPATED (tmpl) = 1;
-	      DECL_FRIEND_P (tmpl) = 1;
-	    }
+	    DECL_FRIEND_P (tmpl) = 1;
 
 	  tmpl = pushdecl_namespace_level (tmpl, /*hiding=*/is_friend);
 	  if (tmpl == error_mark_node)
@@ -11311,11 +11308,6 @@ tsubst_friend_class (tree friend_tmpl, tree args)
 	  CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl))
 	    = INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl)));
 
-	  /* It is hidden.  */
-	  retrofit_lang_decl (DECL_TEMPLATE_RESULT (tmpl));
-	  DECL_ANTICIPATED (tmpl)
-	    = DECL_ANTICIPATED (DECL_TEMPLATE_RESULT (tmpl)) = true;
-
 	  /* Substitute into and set the constraints on the new declaration.  */
 	  if (tree ci = get_constraints (friend_tmpl))
 	    {
diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc
index 3fe310dbb8e..98174250585 100644
--- a/libcc1/libcp1plugin.cc
+++ b/libcc1/libcp1plugin.cc
@@ -353,7 +353,6 @@ supplement_binding (cxx_binding *binding, tree decl)
 	   /* If TARGET_BVAL is anticipated but has not yet been
 	      declared, pretend it is not there at all.  */
 	   || (TREE_CODE (target_bval) == FUNCTION_DECL
-	       && DECL_ANTICIPATED (target_bval)
 	       && DECL_BUILTIN_P (target_bval)))
     binding->value = decl;
   else if (TREE_CODE (target_bval) == TYPE_DECL


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-02 19:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 19:26 [gcc r11-3634] c++: Kill DECL_ANTICIPATED 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).