decl.c (grokdeclarator): Copy array typedef handling from C frontend.
authorJason Merrill <jason@redhat.com>
Mon, 1 Oct 2001 13:18:49 +0000 (09:18 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 1 Oct 2001 13:18:49 +0000 (09:18 -0400)
        * decl.c (grokdeclarator): Copy array typedef handling from C
        frontend.

        * decl.c (grokdeclarator): Copy too-large array handling from C
        frontend.

        * stor-layout.c (layout_type): Don't complain about too-large
        array here.

From-SVN: r45923

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/stor-layout.c

index 8993b5ac05b97df1694083fb599e383d38631889..a2247bd4778bcbd0faf37ab048623723fc9ea782 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-01  Jason Merrill  <jason_merrill@redhat.com>
+
+       * stor-layout.c (layout_type): Don't complain about too-large
+       array here.
+
 Mon Oct  1 06:43:41 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * function.c (keep_stack_depressed): Don't use delete_insn.
index 44cfc47daf18500a1e9a2b601a0c1947038c51b2..b65644ad0589bcc4035d03fbdf288716144b00c9 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-01  Jason Merrill  <jason_merrill@redhat.com>
+
+       * decl.c (grokdeclarator): Copy array typedef handling from C
+       frontend.
+
+       * decl.c (grokdeclarator): Copy too-large array handling from C
+       frontend.
+
 2001-09-29  Alexandre Oliva  <aoliva@redhat.com>
 
        * config-lang.in (target_libs): Added target-gperf, so that we
index 0402d77edd43151c3faa1f59795b3f70a5b365d7..dc4eb8116e941abd5391b101c2883a0edb78d925 100644 (file)
@@ -10888,6 +10888,18 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
 
   /* Now TYPE has the actual type.  */
 
+  /* Did array size calculations overflow?  */
+
+  if (TREE_CODE (type) == ARRAY_TYPE
+      && COMPLETE_TYPE_P (type)
+      && TREE_OVERFLOW (TYPE_SIZE (type)))
+    {
+      error ("size of array `%s' is too large", name);
+      /* If we proceed with the array type as it is, we'll eventully
+        crash in tree_low_cst().  */
+      type = error_mark_node;
+    }
+
   if (explicitp == 1 || (explicitp && friendp))
     {
       /* [dcl.fct.spec] The explicit specifier shall only be used in
@@ -11037,8 +11049,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
      a distinct type, so that each identifier's size can be
      controlled separately by its own initializer.  */
 
-  if (type == typedef_type && TREE_CODE (type) == ARRAY_TYPE
-      && TYPE_DOMAIN (type) == NULL_TREE)
+  if (type != 0 && typedef_type != 0
+      && TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0
+      && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type))
     {
       type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type));
     }
index 57b839f7724bce40463b9bf79e2246934ed6add5..3ff8726b1a30ea7d00558bd259d804b6e3c17aa4 100644 (file)
@@ -1443,26 +1443,6 @@ layout_type (type)
            if (TYPE_SIZE_UNIT (element) != 0 && ! integer_onep (element_size))
              TYPE_SIZE_UNIT (type)
                = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (element), length);
-
-           /* Complain if the user has requested an array too large to
-              fit in size_t.
-
-              ??? Disable this test for signed sizetypes.  This has the effect
-              of disabling it for Ada, where it will cause trouble.  However,
-              this test doesn't make sense for C either since there should
-              be no problem with a type whose size overflows, only an
-              object whose size overflows.  */
-           if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-               && TREE_OVERFLOW (TYPE_SIZE (type))
-               && TREE_UNSIGNED (TREE_TYPE (TYPE_SIZE (type))))
-             {
-               error ("requested array too large for target");
-
-               /* Avoid crashing later.  */
-               TYPE_SIZE (type) = element_size;
-               if (TYPE_SIZE_UNIT (type))
-                 TYPE_SIZE_UNIT (type) = TYPE_SIZE_UNIT (element);
-             }
          }
 
        /* Now round the alignment and size,