Commit 71653180 by Nathan Sidwell Committed by Nathan Sidwell

tree.h (VOID_TYPE_P): New macro.

	* tree.h (VOID_TYPE_P): New macro.
	(COMPLETE_OR_VOID_TYPE_P): Use VOID_TYPE_P.
	* c-decl.c (grokdeclarator): Use VOID_TYPE_P.
	(get_parm_info): Likewise.
	(store_parm_decls): Likewise.
	(combine_parm_decls): Likewise.
	(finish_function): Likewise.
	* c-typeck.c (build_function_call): Likewise.
	(build_binary_op): Likewise.
	(build_conditional_expr): Likewise.
	(internal_build_compound_expr): Likewise.
	(convert_for_assignment): Likewise.
	* stmt.c (expend_expr_stmt): Likewise.
	(warn_if_unused_value): Likewise.
	(expand_return): Likewise.
	* c-parse.in (primary): Likewise.
	* c-parse.y, c-parse.c, c-parse.h: Regenerate.
	* objc/objc-parse.y, objc/objc-parse.c: Regenerate.

From-SVN: r34402
parent 19331b53
2000-06-05 Nathan Sidwell <nathan@codesourcery.com>
* tree.h (VOID_TYPE_P): New macro.
(COMPLETE_OR_VOID_TYPE_P): Use VOID_TYPE_P.
* c-decl.c (grokdeclarator): Use VOID_TYPE_P.
(get_parm_info): Likewise.
(store_parm_decls): Likewise.
(combine_parm_decls): Likewise.
(finish_function): Likewise.
* c-typeck.c (build_function_call): Likewise.
(build_binary_op): Likewise.
(build_conditional_expr): Likewise.
(internal_build_compound_expr): Likewise.
(convert_for_assignment): Likewise.
* stmt.c (expend_expr_stmt): Likewise.
(warn_if_unused_value): Likewise.
(expand_return): Likewise.
* c-parse.in (primary): Likewise.
* c-parse.y, c-parse.c, c-parse.h: Regenerate.
* objc/objc-parse.y, objc/objc-parse.c: Regenerate.
Mon Jun 5 06:46:28 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* alias.c (get_alias_set): If compnent is addressable, use alias
......
......@@ -4290,7 +4290,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
/* Check for some types that there cannot be arrays of. */
if (TYPE_MAIN_VARIANT (type) == void_type_node)
if (VOID_TYPE_P (type))
{
error ("declaration of `%s' as array of voids", name);
type = error_mark_node;
......@@ -4598,7 +4598,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
We don't complain about parms either, but that is because
a better error message can be made later. */
if (TYPE_MAIN_VARIANT (type) == void_type_node && decl_context != PARM
if (VOID_TYPE_P (type) && decl_context != PARM
&& ! ((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
&& ((specbits & (1 << (int) RID_EXTERN))
|| (current_binding_level == global_binding_level
......@@ -4725,7 +4725,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
pedwarn ("ANSI C forbids qualified function types");
if (pedantic
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl))) == void_type_node
&& VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl)))
&& TYPE_QUALS (TREE_TYPE (TREE_TYPE (decl)))
&& ! DECL_IN_SYSTEM_HEADER (decl))
pedwarn ("ANSI C forbids qualified void function return type");
......@@ -4733,7 +4733,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
/* GNU C interprets a `volatile void' return type to indicate
that the function does not return. */
if ((type_quals & TYPE_QUAL_VOLATILE)
&& TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
warning ("`noreturn' function returns non-void value");
if (extern_ref)
......@@ -4948,7 +4948,7 @@ get_parm_info (void_at_end)
/* Just `void' (and no ellipsis) is special. There are really no parms. */
if (void_at_end && parms != 0
&& TREE_CHAIN (parms) == 0
&& TYPE_MAIN_VARIANT (TREE_TYPE (parms)) == void_type_node
&& VOID_TYPE_P (TREE_TYPE (parms))
&& DECL_NAME (parms) == 0)
{
parms = NULL_TREE;
......@@ -5009,7 +5009,7 @@ get_parm_info (void_at_end)
DECL_ARG_TYPE (decl) = integer_type_node;
types = tree_cons (NULL_TREE, TREE_TYPE (decl), types);
if (TYPE_MAIN_VARIANT (TREE_VALUE (types)) == void_type_node && ! erred
if (VOID_TYPE_P (TREE_VALUE (types)) && ! erred
&& DECL_NAME (decl) == 0)
{
error ("`void' in parameter list must be the entire list");
......@@ -5993,8 +5993,7 @@ store_parm_decls ()
if (DECL_NAME (parm) == 0)
error_with_decl (parm, "parameter name omitted");
else if (TREE_CODE (TREE_TYPE (parm)) != ERROR_MARK
&& (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
== void_type_node))
&& VOID_TYPE_P (TREE_TYPE (parm)))
{
error_with_decl (parm, "parameter `%s' declared void");
/* Change the type to error_mark_node so this parameter
......@@ -6097,7 +6096,7 @@ store_parm_decls ()
}
/* If the declaration says "void", complain and ignore it. */
if (found && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == void_type_node)
if (found && VOID_TYPE_P (TREE_TYPE (found)))
{
error_with_decl (found, "parameter `%s' declared void");
TREE_TYPE (found) = integer_type_node;
......@@ -6395,7 +6394,7 @@ combine_parm_decls (specparms, parmlist, void_at_end)
}
/* If the declaration says "void", complain and ignore it. */
if (found && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == void_type_node)
if (found && VOID_TYPE_P (TREE_TYPE (found)))
{
error_with_decl (found, "parameter `%s' declared void");
TREE_TYPE (found) = integer_type_node;
......@@ -6567,7 +6566,7 @@ finish_function (nested)
if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
warning ("`noreturn' function does return");
else if (warn_return_type && can_reach_end
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl))) != void_type_node)
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl))))
/* If this function returns non-void and control can drop through,
complain. */
warning ("control reaches end of non-void function");
......
......@@ -733,8 +733,7 @@ end ifobjc
IDENTIFIER_POINTER (DECL_NAME ($$)));
else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
!= TYPE_MODE (integer_type_node))
&& (TREE_TYPE (TREE_TYPE ($$))
!= void_type_node))
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE ($$))))
pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
IDENTIFIER_POINTER (DECL_NAME ($$)));
/* If it really returns void, change that to int. */
......
......@@ -639,8 +639,7 @@ primary:
IDENTIFIER_POINTER (DECL_NAME ($$)));
else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
!= TYPE_MODE (integer_type_node))
&& (TREE_TYPE (TREE_TYPE ($$))
!= void_type_node))
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE ($$))))
pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
IDENTIFIER_POINTER (DECL_NAME ($$)));
/* If it really returns void, change that to int. */
......
......@@ -1467,7 +1467,7 @@ build_function_call (function, params)
function, coerced_params, NULL_TREE);
TREE_SIDE_EFFECTS (result) = 1;
if (TREE_TYPE (result) == void_type_node)
if (VOID_TYPE_P (TREE_TYPE (result)))
return result;
return require_complete_type (result);
}
......@@ -2099,7 +2099,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
and both must be object or both incomplete. */
if (comp_target_types (type0, type1))
result_type = common_type (type0, type1);
else if (TYPE_MAIN_VARIANT (tt0) == void_type_node)
else if (VOID_TYPE_P (tt0))
{
/* op0 != orig_op0 detects the case of something
whose value is 0 but which isn't a valid null ptr const. */
......@@ -2107,7 +2107,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
&& TREE_CODE (tt1) == FUNCTION_TYPE)
pedwarn ("ANSI C forbids comparison of `void *' with function pointer");
}
else if (TYPE_MAIN_VARIANT (tt1) == void_type_node)
else if (VOID_TYPE_P (tt1))
{
if (pedantic && (!integer_zerop (op1) || op1 != orig_op1)
&& TREE_CODE (tt0) == FUNCTION_TYPE)
......@@ -3408,13 +3408,13 @@ build_conditional_expr (ifexp, op1, op2)
else if (integer_zerop (op2) && TREE_TYPE (type2) == void_type_node
&& TREE_CODE (orig_op2) != NOP_EXPR)
result_type = qualify_type (type1, type2);
else if (TYPE_MAIN_VARIANT (TREE_TYPE (type1)) == void_type_node)
else if (VOID_TYPE_P (TREE_TYPE (type1)))
{
if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
pedwarn ("ANSI C forbids conditional expr between `void *' and function pointer");
result_type = qualify_type (type1, type2);
}
else if (TYPE_MAIN_VARIANT (TREE_TYPE (type2)) == void_type_node)
else if (VOID_TYPE_P (TREE_TYPE (type2)))
{
if (pedantic && TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)
pedwarn ("ANSI C forbids conditional expr between `void *' and function pointer");
......@@ -3533,7 +3533,7 @@ internal_build_compound_expr (list, first_p)
any side-effects, 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");
/* When pedantic, a compound expression can be neither an lvalue
......@@ -4010,8 +4010,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
and vice versa; otherwise, targets must be the same.
Meanwhile, the lhs target must have all the qualifiers of
the rhs. */
if (TYPE_MAIN_VARIANT (ttl) == void_type_node
|| TYPE_MAIN_VARIANT (ttr) == void_type_node
if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
|| comp_target_types (memb_type, rhstype))
{
/* If this type won't generate any warnings, use it. */
......@@ -4086,17 +4085,15 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
/* Any non-function converts to a [const][volatile] void *
and vice versa; otherwise, targets must be the same.
Meanwhile, the lhs target must have all the qualifiers of the rhs. */
if (TYPE_MAIN_VARIANT (ttl) == void_type_node
|| TYPE_MAIN_VARIANT (ttr) == void_type_node
if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
|| comp_target_types (type, rhstype)
|| (unsigned_type (TYPE_MAIN_VARIANT (ttl))
== unsigned_type (TYPE_MAIN_VARIANT (ttr))))
{
if (pedantic
&& ((TYPE_MAIN_VARIANT (ttl) == void_type_node
&& TREE_CODE (ttr) == FUNCTION_TYPE)
&& ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
||
(TYPE_MAIN_VARIANT (ttr) == void_type_node
(VOID_TYPE_P (ttr)
/* Check TREE_CODE to catch cases like (void *) (char *) 0
which are not ANSI null ptr constants. */
&& (!integer_zerop (rhs) || TREE_CODE (rhs) == NOP_EXPR)
......@@ -4113,8 +4110,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
errtype, funname, parmnum);
/* If this is not a case of ignoring a mismatch in signedness,
no warning. */
else if (TYPE_MAIN_VARIANT (ttl) == void_type_node
|| TYPE_MAIN_VARIANT (ttr) == void_type_node
else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
|| comp_target_types (type, rhstype))
;
/* If there is a mismatch, do warn. */
......
......@@ -706,8 +706,7 @@ primary:
IDENTIFIER_POINTER (DECL_NAME ($$)));
else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
!= TYPE_MODE (integer_type_node))
&& (TREE_TYPE (TREE_TYPE ($$))
!= void_type_node))
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE ($$))))
pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
IDENTIFIER_POINTER (DECL_NAME ($$)));
/* If it really returns void, change that to int. */
......
......@@ -1860,7 +1860,7 @@ expand_expr_stmt (exp)
if (! TREE_SIDE_EFFECTS (exp)
&& (extra_warnings || warn_unused_value)
&& !(TREE_CODE (exp) == CONVERT_EXPR
&& TREE_TYPE (exp) == void_type_node))
&& VOID_TYPE_P (TREE_TYPE (exp))))
warning_with_file_and_line (emit_filename, emit_lineno,
"statement with no effect");
else if (warn_unused_value)
......@@ -1970,7 +1970,7 @@ warn_if_unused_value (exp)
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
/* Don't warn about values cast to void. */
if (TREE_TYPE (exp) == void_type_node)
if (VOID_TYPE_P (TREE_TYPE (exp)))
return 0;
/* Don't warn about conversions not explicit in the user's program. */
if (TREE_NO_UNUSED_WARNING (exp))
......@@ -2849,7 +2849,7 @@ expand_return (retval)
else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR)
&& TREE_CODE (TREE_OPERAND (retval, 0)) == RESULT_DECL)
retval_rhs = TREE_OPERAND (retval, 1);
else if (TREE_TYPE (retval) == void_type_node)
else if (VOID_TYPE_P (TREE_TYPE (retval)))
/* Recognize tail-recursive call to void function. */
retval_rhs = retval;
else
......@@ -3074,7 +3074,7 @@ expand_return (retval)
}
else if (cleanups
&& retval_rhs != 0
&& TREE_TYPE (retval_rhs) != void_type_node
&& !VOID_TYPE_P (TREE_TYPE (retval_rhs))
&& (GET_CODE (result_rtl) == REG
|| (GET_CODE (result_rtl) == PARALLEL)))
{
......
......@@ -453,9 +453,12 @@ extern void tree_class_check_failed PARAMS ((const tree, char,
/* Nonzero if this type is a complete type. */
#define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)
/* Nonzero if this type is the (possibly qualified) void type. */
#define VOID_TYPE_P(NODE) (TYPE_MAIN_VARIANT (NODE) == void_type_node)
/* Nonzero if this type is complete or is cv void. */
#define COMPLETE_OR_VOID_TYPE_P(NODE) \
(COMPLETE_TYPE_P (NODE) || TREE_CODE (NODE) == VOID_TYPE)
(COMPLETE_TYPE_P (NODE) || VOID_TYPE_P (NODE))
/* Nonzero if this type is complete or is an array with unspecified bound. */
#define COMPLETE_OR_UNBOUND_ARRAY_TYPE_P(NODE) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment