aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-08-25 01:48:47 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-08-24 21:48:47 -0400
commit51ddb82e4604cfdcc15d6a7b87b4bb713037205c (patch)
tree47603192b7fb5369e59eeb8e210c6872a63bf58c /gcc/cp/call.c
parent1dd503e847be6268eb3e85504e34c06f26d135f0 (diff)
downloadgcc-51ddb82e4604cfdcc15d6a7b87b4bb713037205c.zip
gcc-51ddb82e4604cfdcc15d6a7b87b4bb713037205c.tar.gz
gcc-51ddb82e4604cfdcc15d6a7b87b4bb713037205c.tar.bz2
typeck.c (convert_for_assignment): Converting from pm of vbase to derived is an error, not a sorry.
* typeck.c (convert_for_assignment): Converting from pm of vbase to derived is an error, not a sorry. * call.c (build_over_call): Use convert_pointer_to_real for 'this'. * class.c (fixed_type_or_null): Rename from resolves_to_fixed_type_p. Return the dynamic type of the expression, if fixed, or null. (resolves_to_fixed_type_p): Use it. Return 0 if the dynamic type does not match the static type. (build_vbase_path): Rename 'alias_this' to 'nonnull'. Use resolves_to_fixed_type_p again. From-SVN: r21958
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7c1e683..5564fa3 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3291,6 +3291,7 @@ build_over_call (cand, args, flags)
{
tree parmtype = TREE_VALUE (parm);
tree argtype = TREE_TYPE (TREE_VALUE (arg));
+ tree t;
if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)))
{
int dv = (TYPE_VOLATILE (TREE_TYPE (parmtype))
@@ -3303,9 +3304,18 @@ build_over_call (cand, args, flags)
cp_pedwarn ("passing `%T' as `this' argument of `%#D' discards %s",
TREE_TYPE (argtype), fn, p);
}
- converted_args = expr_tree_cons
- (NULL_TREE, convert_force (TREE_VALUE (parm), TREE_VALUE (arg), CONV_C_CAST),
- converted_args);
+ /* [class.mfct.nonstatic]: If a nonstatic member function of a class
+ X is called for an object that is not of type X, or of a type
+ derived from X, the behavior is undefined.
+
+ So we can assume that anything passed as 'this' is non-null, and
+ optimize accordingly. */
+ if (TREE_CODE (parmtype) == POINTER_TYPE)
+ t = convert_pointer_to_real (TREE_TYPE (parmtype), TREE_VALUE (arg));
+ else
+ /* This happens with signatures. */
+ t = convert_force (parmtype, TREE_VALUE (arg), CONV_C_CAST);
+ converted_args = expr_tree_cons (NULL_TREE, t, converted_args);
parm = TREE_CHAIN (parm);
arg = TREE_CHAIN (arg);
++i;