OSDN Git Service

* init.c (build_new_1): Fill in TYPE_DOMAIN, TYPE_SIZE and
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jun 2004 19:53:14 +0000 (19:53 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jun 2004 19:53:14 +0000 (19:53 +0000)
        TYPE_SIZE_UNIT of full_type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83927 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/init.c

index 8ff4200..1c138da 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-30  Richard Henderson  <rth@redhat.com>
+
+       * init.c (build_new_1): Fill in TYPE_DOMAIN, TYPE_SIZE and
+       TYPE_SIZE_UNIT of full_type.
+
 2004-06-30  Per Bothner  <per@bothner.com>
 
        Conditionally compile support for --enable-mapped_location.
index 4e02b9d..1be0118 100644 (file)
@@ -1815,10 +1815,20 @@ build_new_1 (tree exp)
 
   if (nelts)
     {
+      tree index;
+
       has_array = 1;
       outer_nelts = nelts;
-      /* Use an incomplete array type to avoid VLA headaches.  */
+
+      /* ??? The middle-end will error on us for building a VLA outside a 
+        function context.  Methinks that's not it's purvey.  So we'll do
+        our own VLA layout later.  */
+
       full_type = build_cplus_array_type (type, NULL_TREE);
+
+      index = convert (sizetype, nelts);
+      index = size_binop (MINUS_EXPR, index, size_one_node);
+      TYPE_DOMAIN (full_type) = build_index_type (index);
     }
   else
     full_type = type;
@@ -1857,7 +1867,20 @@ build_new_1 (tree exp)
 
   size = size_in_bytes (true_type);
   if (has_array)
-    size = size_binop (MULT_EXPR, size, convert (sizetype, nelts));
+    {
+      tree n, bitsize;
+
+      /* Do our own VLA layout.  Setting TYPE_SIZE/_UNIT is necessary in
+        order for the <INIT_EXPR <*foo> <CONSTRUCTOR ...>> to be valid.  */
+
+      n = convert (sizetype, nelts);
+      size = size_binop (MULT_EXPR, size, n);
+      TYPE_SIZE_UNIT (full_type) = size;
+
+      n = convert (bitsizetype, nelts);
+      bitsize = size_binop (MULT_EXPR, TYPE_SIZE (true_type), n);
+      TYPE_SIZE (full_type) = bitsize;
+    }
 
   /* Allocate the object.  */
   if (! placement && TYPE_FOR_JAVA (true_type))