mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-20 09:20:42 +08:00
re PR c++/3416 (gcc-3.0 Internal compiler error in arg_assoc, at cp/decl2.c:4902)
cp: PR c++/3416 * call.c (build_conditional_expr): Recheck args after conversions. * cp-tree.h (build_conditional_expr): Move to correct file. * typeck.c (decay_conversion): Diagnose any unknown types reaching here. (build_binary_op): Don't do initial decay or default conversions on overloaded functions. (build_static_cast): Don't do a decay conversion here. testsuite: * g++.old-deja/g++.other/cond7.C: New test. From-SVN: r44345
This commit is contained in:
parent
ab085207aa
commit
4026042933
@ -1,3 +1,15 @@
|
||||
2001-07-25 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/3416
|
||||
* call.c (build_conditional_expr): Recheck args after
|
||||
conversions.
|
||||
* cp-tree.h (build_conditional_expr): Move to correct file.
|
||||
* typeck.c (decay_conversion): Diagnose any unknown types
|
||||
reaching here.
|
||||
(build_binary_op): Don't do initial decay or default
|
||||
conversions on overloaded functions.
|
||||
(build_static_cast): Don't do a decay conversion here.
|
||||
|
||||
2001-07-25 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/3543
|
||||
|
@ -3092,6 +3092,9 @@ build_conditional_expr (arg1, arg2, arg3)
|
||||
arg3 = decay_conversion (arg3);
|
||||
arg3_type = TREE_TYPE (arg3);
|
||||
|
||||
if (arg2 == error_mark_node || arg3 == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
||||
/* [expr.cond]
|
||||
|
||||
After those conversions, one of the following shall hold:
|
||||
|
@ -3545,6 +3545,7 @@ extern int get_arglist_len_in_bytes PARAMS ((tree));
|
||||
|
||||
extern tree build_vfield_ref PARAMS ((tree, tree));
|
||||
extern tree build_scoped_method_call PARAMS ((tree, tree, tree, tree));
|
||||
extern tree build_conditional_expr PARAMS ((tree, tree, tree));
|
||||
extern tree build_addr_func PARAMS ((tree));
|
||||
extern tree build_call PARAMS ((tree, tree));
|
||||
extern tree build_method_call PARAMS ((tree, tree, tree, tree, int));
|
||||
@ -4305,7 +4306,6 @@ extern tree build_x_binary_op PARAMS ((enum tree_code, tree, tree));
|
||||
extern tree build_x_unary_op PARAMS ((enum tree_code, tree));
|
||||
extern tree unary_complex_lvalue PARAMS ((enum tree_code, tree));
|
||||
extern tree build_x_conditional_expr PARAMS ((tree, tree, tree));
|
||||
extern tree build_conditional_expr PARAMS ((tree, tree, tree));
|
||||
extern tree build_x_compound_expr PARAMS ((tree));
|
||||
extern tree build_compound_expr PARAMS ((tree));
|
||||
extern tree build_static_cast PARAMS ((tree, tree));
|
||||
|
@ -1729,6 +1729,12 @@ decay_conversion (exp)
|
||||
if (type == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
||||
if (type_unknown_p (exp))
|
||||
{
|
||||
incomplete_type_error (exp, TREE_TYPE (exp));
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
/* Constants can be used directly unless they're not loadable. */
|
||||
if (TREE_CODE (exp) == CONST_DECL)
|
||||
exp = DECL_INITIAL (exp);
|
||||
@ -3365,17 +3371,24 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
|
||||
int common = 0;
|
||||
|
||||
/* Apply default conversions. */
|
||||
op0 = orig_op0;
|
||||
op1 = orig_op1;
|
||||
|
||||
if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
|
||||
|| code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
|
||||
|| code == TRUTH_XOR_EXPR)
|
||||
{
|
||||
op0 = decay_conversion (orig_op0);
|
||||
op1 = decay_conversion (orig_op1);
|
||||
if (!really_overloaded_fn (op0))
|
||||
op0 = decay_conversion (op0);
|
||||
if (!really_overloaded_fn (op1))
|
||||
op1 = decay_conversion (op1);
|
||||
}
|
||||
else
|
||||
{
|
||||
op0 = default_conversion (orig_op0);
|
||||
op1 = default_conversion (orig_op1);
|
||||
if (!really_overloaded_fn (op0))
|
||||
op0 = default_conversion (op0);
|
||||
if (!really_overloaded_fn (op1))
|
||||
op1 = default_conversion (op1);
|
||||
}
|
||||
|
||||
/* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue. */
|
||||
@ -5100,7 +5113,6 @@ build_static_cast (type, expr)
|
||||
build_tree_list (NULL_TREE, expr),
|
||||
TYPE_BINFO (type), LOOKUP_NORMAL)));
|
||||
|
||||
expr = decay_conversion (expr);
|
||||
intype = TREE_TYPE (expr);
|
||||
|
||||
/* FIXME handle casting to array type. */
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-07-25 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* g++.old-deja/g++.other/cond7.C: New test.
|
||||
|
||||
2001-07-25 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* g++.old-deja/g++.other/optimize4.C: New test.
|
||||
|
26
gcc/testsuite/g++.old-deja/g++.other/cond7.C
Normal file
26
gcc/testsuite/g++.old-deja/g++.other/cond7.C
Normal file
@ -0,0 +1,26 @@
|
||||
// Build don't link:
|
||||
//
|
||||
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 24 Jul 2001 <nathan@codesourcery.com>
|
||||
|
||||
// Bug 3416. We left some unchecked overloaded functions lying around.
|
||||
|
||||
struct X
|
||||
{
|
||||
void operator << (int);
|
||||
void operator << (float);
|
||||
};
|
||||
|
||||
void OVL1 (int);
|
||||
void OVL1 (float);
|
||||
|
||||
void OVL2 (int);
|
||||
void OVL2 (float);
|
||||
|
||||
X x;
|
||||
|
||||
void foo (bool a)
|
||||
{
|
||||
x << (a ? OVL1 : OVL2); // ERROR - incomplete type
|
||||
a ? OVL1 : OVL2; // ERROR - incomplete type
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user