re PR middle-end/55771 (Negation and type conversion incorrectly exchanged)
authorMichael Matz <matz@suse.de>
Fri, 12 Jul 2013 15:41:49 +0000 (15:41 +0000)
committerMichael Matz <matz@gcc.gnu.org>
Fri, 12 Jul 2013 15:41:49 +0000 (15:41 +0000)
PR middle-end/55771
* convert.c (convert_to_real): Reject non-float inner types.

testsuite/
* c-c++-common/pr55771.c: New test.

From-SVN: r200926

gcc/ChangeLog
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr55771.c [new file with mode: 0644]

index bf75708f585f30fddbd59fd98e8a61b691fbaba4..cc3b7daf7907f26d1df6ff93319a2a9d1b8dc2dc 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-12  Michael Matz  <matz@suse.de>
+
+       PR middle-end/55771
+       * convert.c (convert_to_real): Reject non-float inner types.
+
 2013-07-12  Tejas Belagod  <tejas.belagod@arm.com>
 
        * config/aarch64/aarch64-protos.h
index 62ff224b5663707166901341cedb942d69761e52..9ecef4247ba702c6b12d9aa5b24c21278155a7dd 100644 (file)
@@ -213,11 +213,12 @@ convert_to_real (tree type, tree expr)
     switch (TREE_CODE (expr))
       {
        /* Convert (float)-x into -(float)x.  This is safe for
-          round-to-nearest rounding mode.  */
+          round-to-nearest rounding mode when the inner type is float.  */
        case ABS_EXPR:
        case NEGATE_EXPR:
          if (!flag_rounding_math
-             && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr)))
+             && FLOAT_TYPE_P (itype)
+             && TYPE_PRECISION (type) < TYPE_PRECISION (itype))
            return build1 (TREE_CODE (expr), type,
                           fold (convert_to_real (type,
                                                  TREE_OPERAND (expr, 0))));
index 061a8427258b161a550d0225e8487e3a5df0809a..41cea555cd2ec75aea66b2ef42ac96ff68fde83c 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-12  Michael Matz  <matz@suse.de>
+
+       PR middle-end/55771
+       * c-c++-common/pr55771.c: New test.
+
 2013-07-12  Tejas Belagod  <tejas.belagod@arm.com>
 
        * gcc.target/aarch64/vect-movi.c: New.
diff --git a/gcc/testsuite/c-c++-common/pr55771.c b/gcc/testsuite/c-c++-common/pr55771.c
new file mode 100644 (file)
index 0000000..16f0244
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+
+float global;
+int main()
+{
+  unsigned long z = 1;
+  float x = -z;
+  global = x;
+  if (global < 0)
+    __builtin_abort ();
+  return 0;
+}