diff options
Diffstat (limited to 'gcc-4.6/gcc/cp/cvt.c')
-rw-r--r-- | gcc-4.6/gcc/cp/cvt.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/gcc-4.6/gcc/cp/cvt.c b/gcc-4.6/gcc/cp/cvt.c index d26d870a7..0a12dd2a7 100644 --- a/gcc-4.6/gcc/cp/cvt.c +++ b/gcc-4.6/gcc/cp/cvt.c @@ -201,16 +201,14 @@ cp_convert_to_pointer (tree type, tree expr) return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0, /*c_cast_p=*/false, tf_warning_or_error); - if (TYPE_PTRMEM_P (type)) - { - /* A NULL pointer-to-member is represented by -1, not by - zero. */ - expr = build_int_cst_type (type, -1); - } - else - expr = build_int_cst (type, 0); - - return expr; + /* A NULL pointer-to-data-member is represented by -1, not by + zero. */ + tree val = (TYPE_PTRMEM_P (type) + ? build_int_cst_type (type, -1) + : build_int_cst (type, 0)); + + return (TREE_SIDE_EFFECTS (expr) + ? build2 (COMPOUND_EXPR, type, expr, val) : val); } else if (TYPE_PTR_TO_MEMBER_P (type) && INTEGRAL_CODE_P (form)) { |