aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorJeffrey A Law <law@cygnus.com>2001-09-05 13:16:46 +0000
committerJeff Law <law@gcc.gnu.org>2001-09-05 07:16:46 -0600
commit8db4c86715fc58e95cc57f9ea4c9e88c1555e1f2 (patch)
treea3bebd7ab6b588243c494943d8fa9261b5e49f29 /gcc/stor-layout.c
parentcaa297fe38f3cd4f60596e49513c88efb9d31e83 (diff)
downloadgcc-8db4c86715fc58e95cc57f9ea4c9e88c1555e1f2.zip
gcc-8db4c86715fc58e95cc57f9ea4c9e88c1555e1f2.tar.gz
gcc-8db4c86715fc58e95cc57f9ea4c9e88c1555e1f2.tar.bz2
stor-layout.c (layout_type): Complain if an array's size can not be represented in a size_t.
* stor-layout.c (layout_type): Complain if an array's size can not be represented in a size_t. * config/h8300/elf.h (ENDFILE_SPEC, STARTFILE_SPEC): Define. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r45413
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index dfa4c10..3a4f998 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1442,6 +1442,19 @@ 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. */
+ if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+ && TREE_OVERFLOW (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,