This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCHes for c++/43856


And here are a couple of minor code cleanups that I noticed while working on this patch:

commit 70b178b2d846a0bc8231fcdad3b5b9e175f5e676
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Apr 27 21:25:29 2010 +0000

    	* semantics.c (baselink_for_fns): Correct BASELINK_BINFO.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158806 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 05c5168..6bf33c7 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2692,7 +2692,8 @@ baselink_for_fns (tree fns)
   if (!cl)
     cl = DECL_CONTEXT (fn);
   cl = TYPE_BINFO (cl);
-  return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE);
+  return build_baselink (TYPE_BINFO (DECL_CONTEXT (fn)), cl, fns,
+			 /*optype=*/NULL_TREE);
 }
 
 /* Returns true iff DECL is an automatic variable from a function outside

commit 1f07118efd627bef5aed88db1f9d840ce6ab743f
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Apr 27 21:35:17 2010 +0000

    	* tree.c (get_fns): Split out from get_first_fn.
    	* cp-tree.h: Declare it.
    	* search.c (shared_member_p): Use it.
    	* semantics.c (finish_qualified_id_expr): Simplify.
    	(finish_id_expression): Simplify.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158810 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 62e92cc..cbb1ac6 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5259,6 +5259,7 @@ extern tree hash_tree_cons			(tree, tree, tree);
 extern tree hash_tree_chain			(tree, tree);
 extern tree build_qualified_name		(tree, tree, tree, bool);
 extern int is_overloaded_fn			(tree);
+extern tree get_fns				(tree);
 extern tree get_first_fn			(tree);
 extern tree ovl_cons				(tree, tree);
 extern tree build_overload			(tree, tree);
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 772ae3b..11011e7 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -973,6 +973,7 @@ shared_member_p (tree t)
     return 1;
   if (is_overloaded_fn (t))
     {
+      t = get_fns (t);
       for (; t; t = OVL_NEXT (t))
 	{
 	  tree fn = OVL_CURRENT (t);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 73fed15..d4ce014 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1662,15 +1662,11 @@ finish_qualified_id_expr (tree qualifying_class,
     }
   else if (BASELINK_P (expr) && !processing_template_decl)
     {
-      tree fns;
       tree ob;
 
       /* See if any of the functions are non-static members.  */
-      fns = BASELINK_FUNCTIONS (expr);
-      if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
-	fns = TREE_OPERAND (fns, 0);
       /* If so, the expression may be relative to 'this'.  */
-      if (!shared_member_p (fns)
+      if (!shared_member_p (expr)
 	  && (ob = maybe_dummy_object (qualifying_class, NULL),
 	      !is_dummy_object (ob)))
 	expr = (build_class_member_access_expr
@@ -3124,10 +3120,7 @@ finish_id_expression (tree id_expression,
 	{
 	  tree first_fn;
 
-	  first_fn = decl;
-	  if (TREE_CODE (first_fn) == TEMPLATE_ID_EXPR)
-	    first_fn = TREE_OPERAND (first_fn, 0);
-	  first_fn = get_first_fn (first_fn);
+	  first_fn = get_first_fn (decl);
 	  if (TREE_CODE (first_fn) == TEMPLATE_DECL)
 	    first_fn = DECL_TEMPLATE_RESULT (first_fn);
 
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index f8b2c40..4d25cac 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1352,7 +1352,7 @@ really_overloaded_fn (tree x)
 }
 
 tree
-get_first_fn (tree from)
+get_fns (tree from)
 {
   gcc_assert (is_overloaded_fn (from));
   /* A baselink is also considered an overloaded function.  */
@@ -1363,7 +1363,13 @@ get_first_fn (tree from)
     from = BASELINK_FUNCTIONS (from);
   if (TREE_CODE (from) == TEMPLATE_ID_EXPR)
     from = TREE_OPERAND (from, 0);
-  return OVL_CURRENT (from);
+  return from;
+}
+
+tree
+get_first_fn (tree from)
+{
+  return OVL_CURRENT (get_fns (from));
 }
 
 /* Return a new OVL node, concatenating it with the old one.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]