This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Minor code cleanup


Tested on x86_64-suse-linux, applied on the mainline.


2013-10-19  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/cuintp.c: Remove useless include directives.
	(build_cst_from_int): Use standard predicate.
	(UI_To_gnu): Simplify.
	(UI_From_gnu): Fix formatting.
	* gcc-interface/trans.c (post_error): Likewise.
	(post_error_ne): Likewise.


-- 
Eric Botcazou
Index: gcc-interface/cuintp.c
===================================================================
--- gcc-interface/cuintp.c	(revision 203844)
+++ gcc-interface/cuintp.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2012, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2013, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -23,8 +23,8 @@
  *                                                                          *
  ****************************************************************************/
 
-/* This file corresponds to the Ada package body Uintp. It was created
-   manually from the files uintp.ads and uintp.adb. */
+/* This file corresponds to the Ada package body Uintp.  It was created
+   manually from the files uintp.ads and uintp.adb.  */
 
 #include "config.h"
 #include "system.h"
@@ -35,11 +35,6 @@
 #include "ada.h"
 #include "types.h"
 #include "uintp.h"
-#include "atree.h"
-#include "elists.h"
-#include "nlists.h"
-#include "stringt.h"
-#include "fe.h"
 #include "ada-tree.h"
 #include "gigi.h"
 
@@ -53,13 +48,13 @@
    the integer value itself.  The origin of the Uints_Ptr table is adjusted so
    that a Uint value of Uint_Bias indexes the first element.
 
-   First define a utility function that operates like build_int_cst for
-   integral types and does a conversion to floating-point for real types.  */
+   First define a utility function that operates like build_int_cst_type for
+   integral types and does a conversion for floating-point types.  */
 
 static tree
 build_cst_from_int (tree type, HOST_WIDE_INT low)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
     return convert (type, build_int_cst (NULL_TREE, low));
   else
     return build_int_cst_type (type, low);
@@ -73,20 +68,15 @@ build_cst_from_int (tree type, HOST_WIDE
 tree
 UI_To_gnu (Uint Input, tree type)
 {
+  /* We might have a TYPE with biased representation and be passed an unbiased
+     value that doesn't fit.  We always use an unbiased type to be able to hold
+     any such possible value for intermediate computations and then rely on a
+     conversion back to TYPE to perform the bias adjustment when need be.  */
+  tree comp_type
+    = TREE_CODE (type) == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type)
+      ? get_base_type (type) : type;
   tree gnu_ret;
 
-  /* We might have a TYPE with biased representation and be passed an
-     unbiased value that doesn't fit.  We always use an unbiased type able
-     to hold any such possible value for intermediate computations, and
-     then rely on a conversion back to TYPE to perform the bias adjustment
-     when need be.  */
-
-  int biased_type_p
-    = (TREE_CODE (type) == INTEGER_TYPE
-       && TYPE_BIASED_REPRESENTATION_P (type));
-
-  tree comp_type = biased_type_p ? get_base_type (type) : type;
-
   if (Input <= Uint_Direct_Last)
     gnu_ret = build_cst_from_int (comp_type, Input - Uint_Direct_Bias);
   else
@@ -188,12 +178,13 @@ UI_From_gnu (tree Input)
     {
       v[i] = tree_low_cst (fold_build1 (ABS_EXPR, gnu_type,
 					fold_build2 (TRUNC_MOD_EXPR, gnu_type,
-						     gnu_temp, gnu_base)),
-			   0);
+						     gnu_temp, gnu_base)), 0);
       gnu_temp = fold_build2 (TRUNC_DIV_EXPR, gnu_type, gnu_temp, gnu_base);
     }
 
-  temp.Low_Bound = 1, temp.High_Bound = Max_For_Dint;
-  vec.Array = v, vec.Bounds = &temp;
+  temp.Low_Bound = 1;
+  temp.High_Bound = Max_For_Dint;
+  vec.Bounds = &temp;
+  vec.Array = v;
   return Vector_To_Uint (vec, tree_int_cst_sgn (Input) < 0);
 }
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 203844)
+++ gcc-interface/trans.c	(working copy)
@@ -9221,10 +9221,14 @@ post_error (const char *msg, Node_Id nod
   String_Template temp;
   Fat_Pointer fp;
 
-  temp.Low_Bound = 1, temp.High_Bound = strlen (msg);
-  fp.Array = msg, fp.Bounds = &temp;
-  if (Present (node))
-    Error_Msg_N (fp, node);
+  if (No (node))
+    return;
+
+  temp.Low_Bound = 1;
+  temp.High_Bound = strlen (msg);
+  fp.Bounds = &temp;
+  fp.Array = msg;
+  Error_Msg_N (fp, node);
 }
 
 /* Similar to post_error, but NODE is the node at which to post the error and
@@ -9236,10 +9240,14 @@ post_error_ne (const char *msg, Node_Id
   String_Template temp;
   Fat_Pointer fp;
 
-  temp.Low_Bound = 1, temp.High_Bound = strlen (msg);
-  fp.Array = msg, fp.Bounds = &temp;
-  if (Present (node))
-    Error_Msg_NE (fp, node, ent);
+  if (No (node))
+    return;
+
+  temp.Low_Bound = 1;
+  temp.High_Bound = strlen (msg);
+  fp.Bounds = &temp;
+  fp.Array = msg;
+  Error_Msg_NE (fp, node, ent);
 }
 
 /* Similar to post_error_ne, but NUM is the number to use for the '^'.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]