OSDN Git Service

* config/darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not
[pf3gnuchains/gcc-fork.git] / gcc / convert.c
index ab780d8..118889f 100644 (file)
@@ -388,27 +388,36 @@ convert_to_integer (tree type, tree expr)
          /* Only convert in ISO C99 mode.  */
          if (!TARGET_C99_FUNCTIONS)
            break;
-         if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
-           fn = mathfn_built_in (s_intype, BUILT_IN_LLCEIL);
-         else
+         if (outprec < TYPE_PRECISION (long_integer_type_node)
+             || (outprec == TYPE_PRECISION (long_integer_type_node)
+                 && !TYPE_UNSIGNED (type)))
            fn = mathfn_built_in (s_intype, BUILT_IN_LCEIL);
+         else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
+           fn = mathfn_built_in (s_intype, BUILT_IN_LLCEIL);
          break;
 
        CASE_FLT_FN (BUILT_IN_FLOOR):
          /* Only convert in ISO C99 mode.  */
          if (!TARGET_C99_FUNCTIONS)
            break;
-         if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
-           fn = mathfn_built_in (s_intype, BUILT_IN_LLFLOOR);
-         else
+         if (outprec < TYPE_PRECISION (long_integer_type_node)
+             || (outprec == TYPE_PRECISION (long_integer_type_node)
+                 && !TYPE_UNSIGNED (type)))
            fn = mathfn_built_in (s_intype, BUILT_IN_LFLOOR);
+         else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
+           fn = mathfn_built_in (s_intype, BUILT_IN_LLFLOOR);
          break;
 
        CASE_FLT_FN (BUILT_IN_ROUND):
-         if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
-           fn = mathfn_built_in (s_intype, BUILT_IN_LLROUND);
-         else
+         if (outprec < TYPE_PRECISION (long_integer_type_node)
+             || (outprec == TYPE_PRECISION (long_integer_type_node)
+                 && !TYPE_UNSIGNED (type)))
            fn = mathfn_built_in (s_intype, BUILT_IN_LROUND);
+         else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
+           fn = mathfn_built_in (s_intype, BUILT_IN_LLROUND);
          break;
 
        CASE_FLT_FN (BUILT_IN_RINT):
@@ -417,10 +426,13 @@ convert_to_integer (tree type, tree expr)
            break;
          /* ... Fall through ...  */
        CASE_FLT_FN (BUILT_IN_NEARBYINT):
-         if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
-            fn = mathfn_built_in (s_intype, BUILT_IN_LLRINT);
-         else
-            fn = mathfn_built_in (s_intype, BUILT_IN_LRINT);
+         if (outprec < TYPE_PRECISION (long_integer_type_node)
+             || (outprec == TYPE_PRECISION (long_integer_type_node)
+                 && !TYPE_UNSIGNED (type)))
+           fn = mathfn_built_in (s_intype, BUILT_IN_LRINT);
+         else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
+           fn = mathfn_built_in (s_intype, BUILT_IN_LLRINT);
          break;
 
        CASE_FLT_FN (BUILT_IN_TRUNC):
@@ -475,6 +487,7 @@ convert_to_integer (tree type, tree expr)
       else if (outprec >= inprec)
        {
          enum tree_code code;
+         tree tem;
 
          /* If the precision of the EXPR's type is K bits and the
             destination mode has more bits, and the sign is changing,
@@ -492,7 +505,13 @@ convert_to_integer (tree type, tree expr)
          else
            code = NOP_EXPR;
 
-         return fold_build1 (code, type, expr);
+         tem = fold_unary (code, type, expr);
+         if (tem)
+           return tem;
+
+         tem = build1 (code, type, expr);
+         TREE_NO_WARNING (tem) = 1;
+         return tem;
        }
 
       /* If TYPE is an enumeral type or a type with a precision less