call.c (build_conditional_expr): Use VOID_TYPE_P.

* call.c (build_conditional_expr): Use VOID_TYPE_P.
	* cvt.c (cp_convert_to_pointer): Likewise.
	(convert_to_void): Likewise.
	* error.c (dump_expr): Likewise.
	* except.c (complete_ptr_ref_or_void_ptr_p): Likewise.
	* init.c (build_delete): Likewise.
	* method.c (emit_thunk): Likewise.
	* optmize.c (declare_return_variable): Likewise.
	* rtti.c (get_tinfo_decl_dynamic): Likewise.
	(get_typeid): Likewise.
	(build_dynamic_cast_1): Likewise.
	* typeck.c (composite_pointer_type): Likewise.
	(common_type): Likewise.
	(build_indirect_ref): Likewise.
	(build_binary_op): Likewise.
	(build_x_compound_expr): Likewise.
	(check_return_expr): Likewise.
	* typeck2.c (add_exception_specifier): Likewise.

	* mangle.c (write_method_parms): Use direct comparison for end
	of parmlist.

From-SVN: r34617
This commit is contained in:
Nathan Sidwell 2000-06-20 15:42:55 +00:00 committed by Nathan Sidwell
parent 5ea634c774
commit b72801e28a
12 changed files with 56 additions and 42 deletions

View File

@ -1,3 +1,27 @@
2000-06-20 Nathan Sidwell <nathan@codesourcery.com>
* call.c (build_conditional_expr): Use VOID_TYPE_P.
* cvt.c (cp_convert_to_pointer): Likewise.
(convert_to_void): Likewise.
* error.c (dump_expr): Likewise.
* except.c (complete_ptr_ref_or_void_ptr_p): Likewise.
* init.c (build_delete): Likewise.
* method.c (emit_thunk): Likewise.
* optmize.c (declare_return_variable): Likewise.
* rtti.c (get_tinfo_decl_dynamic): Likewise.
(get_typeid): Likewise.
(build_dynamic_cast_1): Likewise.
* typeck.c (composite_pointer_type): Likewise.
(common_type): Likewise.
(build_indirect_ref): Likewise.
(build_binary_op): Likewise.
(build_x_compound_expr): Likewise.
(check_return_expr): Likewise.
* typeck2.c (add_exception_specifier): Likewise.
* mangle.c (write_method_parms): Use direct comparison for end
of parmlist.
2000-06-19 Benjamin Chelf <chelf@cabriolet.stanford.edu>
* cp-tree.h (genrtl_try_block): Declare function.

View File

@ -2858,27 +2858,18 @@ build_conditional_expr (arg1, arg2, arg3)
and third operands. */
arg2_type = TREE_TYPE (arg2);
arg3_type = TREE_TYPE (arg3);
if (same_type_p (TYPE_MAIN_VARIANT (arg2_type), void_type_node)
|| same_type_p (TYPE_MAIN_VARIANT (arg3_type), void_type_node))
if (VOID_TYPE_P (arg2_type) || VOID_TYPE_P (arg3_type))
{
int arg2_void_p;
int arg3_void_p;
/* Do the conversions. We don't these for `void' type arguments
since it can't have any effect and since decay_conversion
does not handle that case gracefully. */
if (!same_type_p (TYPE_MAIN_VARIANT (arg2_type), void_type_node))
if (!VOID_TYPE_P (arg2_type))
arg2 = decay_conversion (arg2);
if (!same_type_p (TYPE_MAIN_VARIANT (arg3_type), void_type_node))
if (!VOID_TYPE_P (arg3_type))
arg3 = decay_conversion (arg3);
arg2_type = TREE_TYPE (arg2);
arg3_type = TREE_TYPE (arg3);
arg2_void_p = same_type_p (TYPE_MAIN_VARIANT (arg2_type),
void_type_node);
arg3_void_p = same_type_p (TYPE_MAIN_VARIANT (arg3_type),
void_type_node);
/* [expr.cond]
One of the following shall hold:
@ -2893,12 +2884,12 @@ build_conditional_expr (arg1, arg2, arg3)
^ (TREE_CODE (arg3) == THROW_EXPR))
result_type = ((TREE_CODE (arg2) == THROW_EXPR)
? arg3_type : arg2_type);
else if (arg2_void_p && arg3_void_p)
else if (VOID_TYPE_P (arg2_type) && VOID_TYPE_P (arg3_type))
result_type = void_type_node;
else
{
cp_error ("`%E' has type `void' and is not a throw-expression",
arg2_void_p ? arg2 : arg3);
VOID_TYPE_P (arg2_type) ? arg2 : arg3);
return error_mark_node;
}

View File

@ -99,7 +99,7 @@ cp_convert_to_pointer (type, expr)
/* Handle anachronistic conversions from (::*)() to cv void* or (*)(). */
if (TREE_CODE (type) == POINTER_TYPE
&& (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
|| TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node))
|| VOID_TYPE_P (TREE_TYPE (type))))
{
/* Allow an implicit this pointer for pointer to member
functions. */
@ -860,7 +860,7 @@ convert_to_void (expr, implicit)
return error_mark_node;
if (!TREE_TYPE (expr))
return expr;
if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (expr)), void_type_node))
if (VOID_TYPE_P (TREE_TYPE (expr)))
return expr;
switch (TREE_CODE (expr))
{
@ -958,8 +958,7 @@ convert_to_void (expr, implicit)
implicit, expr);
}
if (expr != error_mark_node
&& !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (expr)), void_type_node))
if (expr != error_mark_node && !VOID_TYPE_P (TREE_TYPE (expr)))
{
/* FIXME: This is where we should check for expressions with no
effects. At the moment we do that in both build_x_component_expr

View File

@ -1730,9 +1730,11 @@ dump_expr (t, flags)
break;
case CONVERT_EXPR:
if (same_type_p (TREE_TYPE (t), void_type_node))
if (VOID_TYPE_P (TREE_TYPE (t)))
{
OB_PUTS ("(void)");
OB_PUTC ('(');
dump_type (TREE_TYPE (t), flags);
OB_PUTC (')');
dump_expr (TREE_OPERAND (t, 0), flags);
}
else

View File

@ -1073,7 +1073,7 @@ complete_ptr_ref_or_void_ptr_p (type, from)
{
tree core = TREE_TYPE (type);
if (is_ptr && same_type_p (TYPE_MAIN_VARIANT (core), void_type_node))
if (is_ptr && VOID_TYPE_P (core))
/* OK */;
else if (!complete_type_or_else (core, from))
return 0;

View File

@ -3163,7 +3163,7 @@ build_delete (type, addr, auto_delete, flags, use_global_delete)
if (TREE_CODE (type) == POINTER_TYPE)
{
type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
if (type != void_type_node && !complete_type_or_else (type, addr))
if (!VOID_TYPE_P (type) && !complete_type_or_else (type, addr))
return error_mark_node;
if (TREE_CODE (type) == ARRAY_TYPE)
goto handle_array;

View File

@ -1467,7 +1467,7 @@ write_method_parms (parm_list, method_p)
{
tree parm = TREE_VALUE (parm_list);
if (same_type_p (parm, void_type_node))
if (parm == void_type_node)
{
/* "Empty parameter lists, whether declared as () or
conventionally as (void), are encoded with a void parameter

View File

@ -2271,10 +2271,10 @@ emit_thunk (thunk_fndecl)
t = tree_cons (NULL_TREE, a, t);
t = nreverse (t);
t = build_call (function, t);
if (!same_type_p (TREE_TYPE (t), void_type_node))
finish_return_stmt (t);
else
if (VOID_TYPE_P (TREE_TYPE (t)))
finish_expr_stmt (t);
else
finish_return_stmt (t);
/* The back-end expects DECL_INITIAL to contain a BLOCK, so we
create one. */

View File

@ -477,8 +477,7 @@ declare_return_variable (id, use_stmt)
/* We don't need to do anything for functions that don't return
anything. */
if (!result || same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (result)),
void_type_node))
if (!result || VOID_TYPE_P (TREE_TYPE (result)))
{
*use_stmt = NULL_TREE;
return NULL_TREE;

View File

@ -233,7 +233,7 @@ get_tinfo_decl_dynamic (exp)
/* Peel off cv qualifiers. */
type = TYPE_MAIN_VARIANT (type);
if (type != void_type_node)
if (!VOID_TYPE_P (type))
type = complete_type_or_else (type, exp);
if (!type)
@ -513,7 +513,7 @@ get_typeid (type)
that is the operand of typeid are always ignored. */
type = TYPE_MAIN_VARIANT (type);
if (type != void_type_node)
if (!VOID_TYPE_P (type))
type = complete_type_or_else (type, NULL_TREE);
if (!type)
@ -702,8 +702,7 @@ build_dynamic_cast_1 (type, expr)
{
tree expr1;
/* if TYPE is `void *', return pointer to complete object. */
if (tc == POINTER_TYPE
&& TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
if (tc == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type)))
{
/* if b is an object, dynamic_cast<void *>(&b) == (void *)&b. */
if (TREE_CODE (expr) == ADDR_EXPR

View File

@ -443,13 +443,13 @@ composite_pointer_type (t1, t2, arg1, arg2, location)
if (comp_target_types (t1, t2, 1))
result_type = common_type (t1, t2);
else if (TYPE_MAIN_VARIANT (TREE_TYPE (t1)) == void_type_node)
else if (VOID_TYPE_P (TREE_TYPE (t1)))
{
if (pedantic && TREE_CODE (t2) == FUNCTION_TYPE)
pedwarn ("ISO C++ forbids %s between pointer of type `void *' and pointer-to-function", location);
result_type = qualify_type (t1, t2);
}
else if (TYPE_MAIN_VARIANT (TREE_TYPE (t2)) == void_type_node)
else if (VOID_TYPE_P (TREE_TYPE (t2)))
{
if (pedantic && TREE_CODE (t1) == FUNCTION_TYPE)
pedwarn ("ISO C++ forbids %s between pointer of type `void *' and pointer-to-function", location);
@ -600,7 +600,7 @@ common_type (t1, t2)
if (tt1 == tt2)
target = tt1;
else if (tt1 == void_type_node || tt2 == void_type_node)
else if (VOID_TYPE_P (tt1) || VOID_TYPE_P (tt2))
target = void_type_node;
else if (tt1 == unknown_type_node)
target = tt2;
@ -2330,7 +2330,7 @@ build_indirect_ref (ptr, errorstring)
types. */
tree t = canonical_type_variant (TREE_TYPE (type));
if (same_type_p (TYPE_MAIN_VARIANT (t), void_type_node))
if (VOID_TYPE_P (t))
{
/* A pointer to incomplete type (other than cv void) can be
dereferenced [expr.unary.op]/1 */
@ -3582,7 +3582,7 @@ build_binary_op (code, orig_op0, orig_op1)
if (comp_target_types (type0, type1, 1))
result_type = common_type (type0, type1);
else if (tt0 == void_type_node)
else if (VOID_TYPE_P (tt0))
{
if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE
&& tree_int_cst_lt (TYPE_SIZE (type0), TYPE_SIZE (type1)))
@ -3590,7 +3590,7 @@ build_binary_op (code, orig_op0, orig_op1)
else if (TREE_CODE (tt1) == OFFSET_TYPE)
pedwarn ("ISO C++ forbids conversion of a pointer to member to `void *'");
}
else if (tt1 == void_type_node)
else if (VOID_TYPE_P (tt1))
{
if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE
&& tree_int_cst_lt (TYPE_SIZE (type1), TYPE_SIZE (type0)))
@ -5058,7 +5058,7 @@ build_x_compound_expr (list)
unless it was explicitly cast to (void). */
if ((extra_warnings || warn_unused_value)
&& !(TREE_CODE (TREE_VALUE(list)) == CONVERT_EXPR
&& TREE_TYPE (TREE_VALUE(list)) == void_type_node))
&& VOID_TYPE_P (TREE_TYPE (TREE_VALUE(list)))))
warning("left-hand operand of comma expression has no effect");
}
#if 0 /* this requires a gcc backend patch to export warn_if_unused_value */
@ -6799,7 +6799,7 @@ check_return_expr (retval)
result = DECL_RESULT (current_function_decl);
valtype = TREE_TYPE (result);
my_friendly_assert (valtype != NULL_TREE, 19990924);
fn_returns_value_p = !same_type_p (valtype, void_type_node);
fn_returns_value_p = !VOID_TYPE_P (valtype);
if (!retval && DECL_NAME (result) && fn_returns_value_p)
retval = result;
@ -6817,7 +6817,7 @@ check_return_expr (retval)
isn't supposed to return a value. */
else if (retval && !fn_returns_value_p)
{
if (same_type_p (TREE_TYPE (retval), void_type_node))
if (VOID_TYPE_P (TREE_TYPE (retval)))
/* You can return a `void' value from a function of `void'
type. In that case, we have to evaluate the expression for
its side-effects. */

View File

@ -1466,7 +1466,7 @@ add_exception_specifier (list, spec, complain)
core = TREE_TYPE (core);
if (complain < 0)
ok = 1;
else if (TYPE_MAIN_VARIANT (core) == void_type_node)
else if (VOID_TYPE_P (core))
ok = is_ptr;
else if (TREE_CODE (core) == TEMPLATE_TYPE_PARM)
ok = 1;