OSDN Git Service

* gcc-interface/Make-lang.in (GNATLIBFLAGS, GNATLIBCFLAGS, THREAD_KIND,
[pf3gnuchains/gcc-fork.git] / gcc / stor-layout.c
index 8a5c48d..359541e 100644 (file)
@@ -1,7 +1,7 @@
 /* C-compiler utilities for types and variables storage layout
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1996, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+   2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -935,7 +935,8 @@ update_alignment_for_field (record_layout_info rli, tree field,
         applies if there was an immediately prior, nonzero-size
         bitfield.  (That's the way it is, experimentally.) */
       if ((!is_bitfield && !DECL_PACKED (field))
-         || (!integer_zerop (DECL_SIZE (field))
+         || ((DECL_SIZE (field) == NULL_TREE
+              || !integer_zerop (DECL_SIZE (field)))
              ? !DECL_PACKED (field)
              : (rli->prev_field
                 && DECL_BIT_FIELD_TYPE (rli->prev_field)
@@ -1958,16 +1959,15 @@ layout_type (tree type)
            if (integer_zerop (element_size))
              length = size_zero_node;
 
-           /* The computation should happen in the original type so
-              that (possible) negative values are handled appropriately.  */
+           /* The computation should happen in the original signedness so
+              that (possible) negative values are handled appropriately
+              when determining overflow.  */
            else
              length
                = fold_convert (sizetype,
-                               fold_build2 (PLUS_EXPR, TREE_TYPE (lb),
-                                            build_int_cst (TREE_TYPE (lb), 1),
-                                            fold_build2 (MINUS_EXPR,
-                                                         TREE_TYPE (lb),
-                                                         ub, lb)));
+                               size_binop (PLUS_EXPR,
+                                           build_int_cst (TREE_TYPE (lb), 1),
+                                           size_binop (MINUS_EXPR, ub, lb)));
 
            TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
                                           fold_convert (bitsizetype,
@@ -2247,7 +2247,11 @@ initialize_sizetypes (void)
     = size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype)));
   set_min_and_max_values_for_integral_type (bitsizetype, bprecision,
                                            /*is_unsigned=*/true);
-  /* ???  TYPE_MAX_VALUE is not properly sign-extended.  */
+  /* bitsizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is
+     sign-extended in a way consistent with force_fit_type.  */
+  TYPE_MAX_VALUE (bitsizetype)
+    = double_int_to_tree (bitsizetype,
+                         tree_to_double_int (TYPE_MAX_VALUE (bitsizetype)));
 
   /* Create the signed variants of *sizetype.  */
   ssizetype = make_signed_type (TYPE_PRECISION (sizetype));