aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-07-06 03:30:57 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-07-06 03:30:57 +0000
commit0a72704b04e73d1173ae5e1c99464bea55a698b4 (patch)
tree056d5a4f42966fc1a6672ee25eb4c64a77754dbf /gcc/cp/call.c
parentac3d7b441379a5992280022a730eb5b1a57e0784 (diff)
downloadgcc-0a72704b04e73d1173ae5e1c99464bea55a698b4.zip
gcc-0a72704b04e73d1173ae5e1c99464bea55a698b4.tar.gz
gcc-0a72704b04e73d1173ae5e1c99464bea55a698b4.tar.bz2
re PR c++/11431 (static_cast behavior with subclasses when default constructor available)
PR c++/11431 * typeck.c (build_static_cast): Check for reference conversions earlier. * cp-tree.h (perform_integral_promotions): Declare. * call.c (build_addr_func): Use decay_conversion. (convert_arg_to_ellipsis): Likewise. Remove misleading comment. (convert_for_arg_passing): Use perform_integral_promotions. * cvt.c (build_expr_type_conversion): Use decay_conversion. (type_promotes_to): Do not return a cv-qualified type. * decl.c (grok_reference_init): Fix formatting. (get_atexit_node): Use decay_conversion. (build_enumerator): Use perform_integral_promotions. * init.c (build_vec_init): Use decay_conversion. * semantics.c (finish_expr_stmt): Likewise. (finish_switch_cond): Use perform_integral_promotions. * typeck.c (default_conversion): Likewise. (perform_integral_promotions): New function. (build_indirect_ref): Use decay_conversion. (build_array_ref): Use perform_integral_promotions. (convert_arguments): Use decay_conversion. (build_unary_op): Use perform_integral_promotions. (build_c_cast): Use decay_conversion. (build_modify_expr): Likewise. (convert_for_initialization): Likewise. * typeck2.c (build_x_arrow): Likewise. * g++.old-deja/g++.jason/typeid1.C: Make it a compile test, not a run test. PR c++/11431 * g++.dg/expr/static_cast3.C: New test. From-SVN: r68989
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2ae1319..0832df7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -326,7 +326,7 @@ build_addr_func (tree function)
function = build_address (function);
}
else
- function = default_conversion (function);
+ function = decay_conversion (function);
return function;
}
@@ -4339,20 +4339,29 @@ call_builtin_trap (void)
}
/* ARG is being passed to a varargs function. Perform any conversions
- required. Array/function to pointer decay must have already happened.
- Return the converted value. */
+ required. Return the converted value. */
tree
convert_arg_to_ellipsis (tree arg)
{
+ /* [expr.call]
+
+ The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
+ standard conversions are performed. */
+ arg = decay_conversion (arg);
+ /* [expr.call]
+
+ If the argument has integral or enumeration type that is subject
+ to the integral promotions (_conv.prom_), or a floating point
+ type that is subject to the floating point promotion
+ (_conv.fpprom_), the value of the argument is converted to the
+ promoted type before the call. */
if (TREE_CODE (TREE_TYPE (arg)) == REAL_TYPE
&& (TYPE_PRECISION (TREE_TYPE (arg))
< TYPE_PRECISION (double_type_node)))
- /* Convert `float' to `double'. */
arg = cp_convert (double_type_node, arg);
- else
- /* Convert `short' and `char' to full-size `int'. */
- arg = default_conversion (arg);
+ else if (INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (arg)))
+ arg = perform_integral_promotions (arg);
arg = require_complete_type (arg);
@@ -4487,7 +4496,7 @@ convert_for_arg_passing (tree type, tree val)
else if (PROMOTE_PROTOTYPES
&& INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
- val = default_conversion (val);
+ val = perform_integral_promotions (val);
return val;
}