From 11017cc737b10f7eb7544ae55a340584d22fb9a8 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Tue, 12 Aug 2003 01:45:23 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 8 ++++++++ gcc/c-typeck.c | 3 +-- gcc/doc/c-tree.texi | 15 +++++++++++++++ gcc/expr.c | 4 ++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 39d3f20..92b6a3e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2003-08-11 Roger Sayle + * 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 + * fold-const.c (fold): Optimize any associative floating point operator with -funsafe-math-optimizations, not just MULT_EXPR. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 7d29b19..224741b 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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; diff --git a/gcc/doc/c-tree.texi b/gcc/doc/c-tree.texi index e605d73..29ccaec 100644 --- a/gcc/doc/c-tree.texi +++ b/gcc/doc/c-tree.texi @@ -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. diff --git a/gcc/expr.c b/gcc/expr.c index 47c4f92..f2c21c4 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -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. */ -- 2.7.4