diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 17 | ||||
-rw-r--r-- | gcc/stor-layout.c | 20 |
4 files changed, 28 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8993b5a..a2247bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 44cfc47..b65644a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0402d77..dc4eb81 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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)); } diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 57b839f..3ff8726 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -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, |