This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH for conditionals/assignments
>>>>> "Jason" == Jason Merrill <jason@cygnus.com> writes:
Jason> Next time, please use diff -p to generate patches; unified
Jason> diffs are hard to read when changes are large.
OK. Some folks prefer unidiffs. Anyhow, I think you mean `-c'; `-p'
is for showing function names, which I did use.
Jason> "ncp_convert" is an unhelpful name.
Agreed. Kinda like `ocp_convert'. :-)
The attached patch makes this `perform_implicit_conversion'.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-07-26 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (ncp_convert): Rename to perform_implicit_conversion.
* call.c: All uses changed.
* typeck.c: Likewise.
Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.247
diff -u -p -c -r1.247 cp-tree.h
*** cp-tree.h 1999/07/26 08:18:09 1.247
--- cp-tree.h 1999/07/26 18:10:33
*************** extern tree convert_arg_to_ellipsis
*** 2785,2791 ****
extern int is_properly_derived_from PROTO((tree, tree));
extern tree initialize_reference PROTO((tree, tree));
extern tree strip_top_quals PROTO((tree));
! extern tree ncp_convert PROTO((tree, tree));
/* in class.c */
extern tree build_vbase_path PROTO((enum tree_code, tree, tree, tree, int));
--- 2785,2791 ----
extern int is_properly_derived_from PROTO((tree, tree));
extern tree initialize_reference PROTO((tree, tree));
extern tree strip_top_quals PROTO((tree));
! extern tree perform_implicit_conversion PROTO((tree, tree));
/* in class.c */
extern tree build_vbase_path PROTO((enum tree_code, tree, tree, tree, int));
Index: call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.152
diff -u -p -c -r1.152 call.c
*** call.c 1999/07/26 08:18:10 1.152
--- call.c 1999/07/26 18:10:36
*************** build_conditional_expr (arg1, arg2, arg3
*** 2977,2984 ****
/* In this case, there is always a common type. */
result_type = type_after_usual_arithmetic_conversions (arg2_type,
arg3_type);
! arg2 = ncp_convert (result_type, arg2);
! arg3 = ncp_convert (result_type, arg3);
}
/* [expr.cond]
--- 2977,2984 ----
/* In this case, there is always a common type. */
result_type = type_after_usual_arithmetic_conversions (arg2_type,
arg3_type);
! arg2 = perform_implicit_conversion (result_type, arg2);
! arg3 = perform_implicit_conversion (result_type, arg3);
}
/* [expr.cond]
*************** build_conditional_expr (arg1, arg2, arg3
*** 3009,3016 ****
{
result_type = composite_pointer_type (arg2_type, arg3_type, arg2,
arg3, "conditional expression");
! arg2 = ncp_convert (result_type, arg2);
! arg3 = ncp_convert (result_type, arg3);
}
if (!result_type)
--- 3009,3016 ----
{
result_type = composite_pointer_type (arg2_type, arg3_type, arg2,
arg3, "conditional expression");
! arg2 = perform_implicit_conversion (result_type, arg2);
! arg3 = perform_implicit_conversion (result_type, arg3);
}
if (!result_type)
*************** tourney (candidates)
*** 5060,5065 ****
--- 5060,5067 ----
return champ;
}
+ /* Returns non-zero if things of type FROM can be converted to TO. */
+
int
can_convert (to, from)
tree to, from;
*************** can_convert (to, from)
*** 5067,5072 ****
--- 5069,5076 ----
return can_convert_arg (to, from, NULL_TREE);
}
+ /* Returns non-zero if ARG (of type FROM) can be converted to TO. */
+
int
can_convert_arg (to, from, arg)
tree to, from, arg;
*************** can_convert_arg (to, from, arg)
*** 5075,5082 ****
return (t && ! ICS_BAD_FLAG (t));
}
tree
! ncp_convert (type, expr)
tree type;
tree expr;
{
--- 5079,5088 ----
return (t && ! ICS_BAD_FLAG (t));
}
+ /* Convert EXPR to TYPE. Return the converted expression. */
+
tree
! perform_implicit_conversion (type, expr)
tree type;
tree expr;
{
Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.175
diff -u -p -c -r1.175 typeck.c
*** typeck.c 1999/07/26 08:18:11 1.175
--- typeck.c 1999/07/26 18:10:40
*************** convert_for_assignment (type, rhs, errty
*** 6526,6532 ****
errtype);
return error_mark_node;
}
! return ncp_convert (strip_top_quals (type), rhs);
}
/* Convert RHS to be of type TYPE.
--- 6526,6532 ----
errtype);
return error_mark_node;
}
! return perform_implicit_conversion (strip_top_quals (type), rhs);
}
/* Convert RHS to be of type TYPE.