expr.c (expand_expr): If an ABS_EXPR has a complex type, abort.

* expr.c (expand_expr): If an ABS_EXPR has a complex type, abort.
	* c-typeck.c (build_unary_op): COMPLEX_TYPE is not a valid
	typecode for an ABS_EXPR.

	* doc/c-tree.texi: Document ABS_EXPR.

From-SVN: r70349
This commit is contained in:
Roger Sayle 2003-08-12 01:45:23 +00:00 committed by Roger Sayle
parent af7b5c1c00
commit 11017cc737
4 changed files with 26 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2003-08-11 Roger Sayle <roger@eyesopen.com>
* expr.c (expand_expr): If an ABS_EXPR has a complex type, abort.
* c-typeck.c (build_unary_op): COMPLEX_TYPE is not a valid
typecode for an ABS_EXPR.
* doc/c-tree.texi: Document ABS_EXPR.
2003-08-11 Roger Sayle <roger@eyesopen.com>
* fold-const.c (fold): Optimize any associative floating point

View File

@ -2152,8 +2152,7 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
break;
case ABS_EXPR:
if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
|| typecode == COMPLEX_TYPE))
if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
{
error ("wrong type argument to abs");
return error_mark_node;

View File

@ -1720,6 +1720,7 @@ This macro returns the attributes on the type @var{type}.
@findex PTRMEM_CST_MEMBER
@tindex VAR_DECL
@tindex NEGATE_EXPR
@tindex ABS_EXPR
@tindex BIT_NOT_EXPR
@tindex TRUTH_NOT_EXPR
@tindex ADDR_EXPR
@ -1915,6 +1916,20 @@ determined by looking at the type of the expression.
The behavior of this operation on signed arithmetic overflow is
controlled by the @code{flag_wrapv} and @code{flag_trapv} variables.
@item ABS_EXPR
These nodes represent the absolute value of the single operand, for
both integer and floating-point types. This is typically used to
implement the @code{abs}, @code{labs} and @code{llabs} builtins for
integer types, and the @code{fabs}, @code{fabsf} and @code{fabsl}
builtins for floating point types. The type of abs operation can
be determined by looking at the type of the expression.
This node is not used for complex types. To represent the modulus
or complex abs of a complex value, use the @code{BUILT_IN_CABS},
@code{BUILT_IN_CABSF} or @code{BUILT_IN_CABSL} builtins, as used
to implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl}
built-in functions.
@item BIT_NOT_EXPR
These nodes represent bitwise complement, and will always have integral
type. The only operand is the value to be complemented.

View File

@ -8475,10 +8475,10 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode, enum expand_modifier
if (modifier == EXPAND_STACK_PARM)
target = 0;
/* Handle complex values specially. */
/* ABS_EXPR is not valid for complex arguments. */
if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
|| GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
return expand_complex_abs (mode, op0, target, unsignedp);
abort ();
/* Unsigned abs is simply the operand. Testing here means we don't
risk generating incorrect code below. */