OSDN Git Service

Fix for PR libgcj/6081:
[pf3gnuchains/gcc-fork.git] / gcc / stor-layout.c
index 671d65a..baf26dd 100644 (file)
@@ -31,6 +31,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "toplev.h"
 #include "ggc.h"
 #include "target.h"
+#include "langhooks.h"
 
 /* Set to one when set_sizetype has been called.  */
 static int sizetype_set;
@@ -151,7 +152,8 @@ variable_size (size)
      just return SIZE unchanged.  Likewise for self-referential sizes and
      constant sizes.  */
   if (TREE_CONSTANT (size)
-      || global_bindings_p () < 0 || contains_placeholder_p (size))
+      || (*lang_hooks.decls.global_bindings_p) () < 0
+      || contains_placeholder_p (size))
     return size;
 
   size = save_expr (size);
@@ -167,7 +169,7 @@ variable_size (size)
   if (TREE_CODE (size) == SAVE_EXPR)
     SAVE_EXPR_PERSISTENT_P (size) = 1;
 
-  if (global_bindings_p ())
+  if ((*lang_hooks.decls.global_bindings_p) ())
     {
       if (TREE_CONSTANT (size))
        error ("type size can't be explicitly evaluated");
@@ -1582,8 +1584,13 @@ layout_type (type)
            && (TYPE_MODE (TREE_TYPE (type)) != BLKmode
                || TYPE_NO_FORCE_BLK (TREE_TYPE (type))))
          {
-           TYPE_MODE (type)
-             = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
+           /* One-element arrays get the component type's mode.  */
+           if (simple_cst_equal (TYPE_SIZE (type),
+                                 TYPE_SIZE (TREE_TYPE (type))))
+             TYPE_MODE (type) = TYPE_MODE (TREE_TYPE (type));
+           else
+             TYPE_MODE (type)
+               = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
 
            if (TYPE_MODE (type) != BLKmode
                && STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
@@ -1816,8 +1823,7 @@ set_sizetype (type)
       TYPE_REFERENCE_TO (sizetype_tab[i]) = 0;
     }
 
-  ggc_add_tree_root ((tree *) &sizetype_tab,
-                    sizeof sizetype_tab / sizeof (tree));
+  ggc_add_tree_root ((tree *) &sizetype_tab, ARRAY_SIZE (sizetype_tab));
 
   /* Go down each of the types we already made and set the proper type
      for the sizes in them.  */