This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch] PR C++/12574
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, mark at codesourcery dot com
- Date: Tue, 14 Oct 2003 10:46:33 +0200
- Subject: [C++ patch] PR C++/12574
Hi,
the testcase shows that there is yet another way to reffer to functiona
ddress using baselink expression. I am not quite sure I deal with all
cases correctly as perhaps I should do something about TEMPLATE_DECL and
OVERLOAD too. Mark?
Honza
Tue Oct 14 10:44:02 CEST 2003 Jan Hubicka <jh@suse.cz>
PR C++/12574
* cgraphunit.c (record_call_1): Call analyze_expr on ADDR_EXPRs of
ununderstood object.
* decl2.c (cxx_callgraph_analyze_expr): Deal with ADDR_EXPR of BASELINK.
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.35
diff -c -3 -p -r1.35 cgraphunit.c
*** cgraphunit.c 12 Oct 2003 09:06:26 -0000 1.35
--- cgraphunit.c 14 Oct 2003 08:43:40 -0000
*************** record_call_1 (tree *tp, int *walk_subtr
*** 243,248 ****
--- 243,253 ----
/* Record dereferences to the functions. This makes the
functions reachable unconditionally. */
tree decl = TREE_OPERAND (*tp, 0);
+
+ /* In C++ we may have BASELINK construct embedded. */
+ if ((unsigned int) TREE_CODE (decl) >= LAST_AND_UNUSED_TREE_CODE)
+ return (*lang_hooks.callgraph.analyze_expr) (tp, walk_subtrees, data);
+
if (TREE_CODE (decl) == FUNCTION_DECL)
cgraph_mark_needed_node (cgraph_node (decl));
}
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.682
diff -c -3 -p -r1.682 decl2.c
*** cp/decl2.c 28 Sep 2003 04:37:40 -0000 1.682
--- cp/decl2.c 14 Oct 2003 08:43:42 -0000
*************** cxx_callgraph_analyze_expr (tree *tp, in
*** 2582,2587 ****
--- 2582,2606 ----
if (TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
cgraph_mark_needed_node (cgraph_node (PTRMEM_CST_MEMBER (t)));
break;
+ case ADDR_EXPR:
+ if (flag_unit_at_a_time)
+ {
+ /* Record dereferences to the functions. This makes the
+ functions reachable unconditionally. */
+ tree op = TREE_OPERAND (*tp, 0);
+ tree fns;
+
+ if (TREE_CODE (op) != BASELINK)
+ return NULL;
+
+ for (fns = BASELINK_FUNCTIONS (op); fns; fns = OVL_NEXT (fns))
+ {
+ tree fn = OVL_CURRENT (fns);
+
+ if (TREE_CODE (fn) == FUNCTION_DECL)
+ cgraph_mark_needed_node (cgraph_node (fn));
+ }
+ }
default:
break;