OSDN Git Service

* expr.c (expand_expr): If an ABS_EXPR has a complex type, abort.
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Aug 2003 01:45:23 +0000 (01:45 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Aug 2003 01:45:23 +0000 (01:45 +0000)
* c-typeck.c (build_unary_op): COMPLEX_TYPE is not a valid
typecode for an ABS_EXPR.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70349 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-typeck.c
gcc/doc/c-tree.texi
gcc/expr.c

index 39d3f20..92b6a3e 100644 (file)
@@ -1,5 +1,13 @@
 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
        operator with -funsafe-math-optimizations, not just MULT_EXPR.
 
index 7d29b19..224741b 100644 (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;
index e605d73..29ccaec 100644 (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.
index 47c4f92..f2c21c4 100644 (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.  */