C++ PATCH to static member access
Jason Merrill
jason@redhat.com
Tue Jan 2 07:15:00 GMT 2001
Fixes g++.martin/eval1.C, g++.other/static16.C.
2001-01-02 Jason Merrill <jason@redhat.com>
* call.c (build_new_method_call): Do evaluate the object parameter
when accessing a static member.
* typeck.c (build_component_ref): Likewise.
*** call.c.~1~ Sat Dec 30 00:22:25 2000
--- call.c Sat Dec 30 00:22:27 2000
*************** build_new_method_call (instance, name, a
*** 4278,4283 ****
--- 4278,4284 ----
tree pretty_name;
tree user_args;
tree templates = NULL_TREE;
+ tree call;
int template_only = 0;
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
*************** build_new_method_call (instance, name, a
*** 4492,4501 ****
|| resolves_to_fixed_type_p (instance, 0)))
flags |= LOOKUP_NONVIRTUAL;
! return build_over_call
! (cand,
! TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE ? mem_args : args,
! flags);
}
/* Returns non-zero iff standard conversion sequence ICS1 is a proper
--- 4493,4510 ----
|| resolves_to_fixed_type_p (instance, 0)))
flags |= LOOKUP_NONVIRTUAL;
! if (TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE)
! call = build_over_call (cand, mem_args, flags);
! else
! {
! call = build_over_call (cand, args, flags);
! /* Do evaluate the object parameter in a call to a static member
! function. */
! if (TREE_SIDE_EFFECTS (instance))
! call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call);
! }
!
! return call;
}
/* Returns non-zero iff standard conversion sequence ICS1 is a proper
*** typeck.c.~1~ Sat Dec 30 00:22:25 2000
--- typeck.c Tue Jan 2 15:09:17 2001
*************** build_component_ref (datum, component, b
*** 2208,2213 ****
--- 2208,2218 ----
mark_used (field);
else
TREE_USED (field) = 1;
+
+ /* Do evaluate the object when accessing a static member. */
+ if (TREE_SIDE_EFFECTS (datum))
+ field = build (COMPOUND_EXPR, TREE_TYPE (field), datum, field);
+
return field;
}
}
More information about the Gcc-patches
mailing list