c-typeck.c (c_common_type): Prefer double_type_node over other REAL_TYPE types with...
authorJoern Rennecke <joern.rennecke@embecosm.com>
Mon, 26 Aug 2013 16:22:37 +0000 (16:22 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Mon, 26 Aug 2013 16:22:37 +0000 (17:22 +0100)
        * c-typeck.c (c_common_type): Prefer double_type_node over
        other REAL_TYPE types with the same precision.
        (convert_arguments): Likewise.

From-SVN: r202004

gcc/c/ChangeLog
gcc/c/c-typeck.c

index 574e7c073ca41293b8808e801b82afa65fc42fdb..4d32d6dce3db62ccac4aaa35383a9e794db1d1ac 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-26  Joern Rennecke  <joern.rennecke@embecosm.com>
+
+       * c-typeck.c (c_common_type): Prefer double_type_node over
+       other REAL_TYPE types with the same precision.
+       (convert_arguments): Likewise.
+
 2013-08-23  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * c-objc-common.c (c_tree_printer): Document the nature of the cast.
index 30871db3623a08f0e836d5ae7aa468dd7f5ddba8..5daae23d14169a06c505bf2b8002e451ff0222d5 100644 (file)
@@ -919,6 +919,13 @@ c_common_type (tree t1, tree t2)
       || TYPE_MAIN_VARIANT (t2) == long_double_type_node)
     return long_double_type_node;
 
+  /* Likewise, prefer double to float even if same size.
+     We got a couple of embedded targets with 32 bit doubles, and the
+     pdp11 might have 64 bit floats.  */
+  if (TYPE_MAIN_VARIANT (t1) == double_type_node
+      || TYPE_MAIN_VARIANT (t2) == double_type_node)
+    return double_type_node;
+
   /* Otherwise prefer the unsigned one.  */
 
   if (TYPE_UNSIGNED (t1))
@@ -3156,7 +3163,9 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values,
        }
       else if (TREE_CODE (valtype) == REAL_TYPE
               && (TYPE_PRECISION (valtype)
-                  < TYPE_PRECISION (double_type_node))
+                  <= TYPE_PRECISION (double_type_node))
+              && valtype != double_type_node
+              && valtype != long_double_type_node
               && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (valtype)))
         {
          if (type_generic)