re PR target/10768 (ICEs on compilation of ada support library for avr)
authorTristan Gingold <gingold@adacore.com>
Tue, 8 Apr 2008 06:46:04 +0000 (08:46 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 8 Apr 2008 06:46:04 +0000 (08:46 +0200)
2008-04-08  Tristan Gingold  <gingold@adacore.com>

PR ada/10768

* cuintp.c: Fix 16 bits issue for AVR.
On AVR, integer is 16 bits, so it can't be used to do math with
Base (=32768).
So use long_integer instead.

From-SVN: r134013

gcc/ada/cuintp.c

index ba3ffa0..90ea342 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2007, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2008, 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- *
@@ -101,11 +101,15 @@ UI_To_gnu (Uint Input, tree type)
         large as an integer not to overflow.  REAL types are always fine, but
         INTEGER or ENUMERAL types we are handed may be too short.  We use a
         base integer type node for the computations in this case and will
-        convert the final result back to the incoming type later on.  */
+        convert the final result back to the incoming type later on.
+        The base integer precision must be superior than 16.  */
 
       if (TREE_CODE (comp_type) != REAL_TYPE
-         && TYPE_PRECISION (comp_type) < TYPE_PRECISION (integer_type_node))
-       comp_type = integer_type_node;
+         && TYPE_PRECISION (comp_type) < TYPE_PRECISION (long_integer_type_node))
+       {
+         comp_type = long_integer_type_node;
+         gcc_assert (TYPE_PRECISION (comp_type) > 16);
+       }
 
       gnu_base = build_cst_from_int (comp_type, Base);