diff options
author | Carlos O'Donell <carlos@codesourcery.com> | 2006-04-20 00:21:51 +0000 |
---|---|---|
committer | Carlos O'Donell <carlos@gcc.gnu.org> | 2006-04-20 00:21:51 +0000 |
commit | 9dfb66b9fe85b353f0efed3a98745f6c686511c1 (patch) | |
tree | 2915a6e02f9f6c44b4b02c47404a627e46d27ab4 /gcc | |
parent | 4fc1015b1dc9007e5ebf68794e0212daee5449b5 (diff) | |
download | gcc-9dfb66b9fe85b353f0efed3a98745f6c686511c1.zip gcc-9dfb66b9fe85b353f0efed3a98745f6c686511c1.tar.gz gcc-9dfb66b9fe85b353f0efed3a98745f6c686511c1.tar.bz2 |
re PR c/26774 (Out of memory compiling 9-line Delta-reduced Linux kernel driver msp3400.c)
gcc/
2006-04-19 Carlos O'Donell <carlos@codesourcery.com>
Nathan Sidwell <nathan@codesourcery.com>
PR c/26774
* stor-layout.c (update_alignment_for_field): Do not align
ERROR_MARK nodes.
(place_union_field): Place union field at the start of the union.
(place_field): Move ERROR_MARK check later, and use the current
allocation position to maintain monotonicity.
gcc/testsuite/
2006-04-19 Carlos O'Donell <carlos@codesourcery.com>
PR c/26774
* gcc.dg/struct-parse-1.c: New test case.
Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>
From-SVN: r113107
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/stor-layout.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/struct-parse-1.c | 11 |
4 files changed, 46 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6342fd9..4024933 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2006-04-19 Carlos O'Donell <carlos@codesourcery.com> + Nathan Sidwell <nathan@codesourcery.com> + + PR c/26774 + * stor-layout.c (update_alignment_for_field): Do not align + ERROR_MARK nodes. + (place_union_field): Place union field at the start of the union. + (place_field): Move ERROR_MARK check later, and use the current + allocation position to maintain monotonicity. + 2006-04-19 Zdenek Dvorak <dvorakz@suse.cz> * dominance.c: Include timevar.h. diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 723e0689..b95e075 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -663,6 +663,10 @@ update_alignment_for_field (record_layout_info rli, tree field, bool user_align; bool is_bitfield; + /* Do not attempt to align an ERROR_MARK node */ + if (TREE_CODE (type) == ERROR_MARK) + return 0; + /* Lay out the field so we know what alignment it needs. */ layout_decl (field, known_align); desired_align = DECL_ALIGN (field); @@ -775,6 +779,12 @@ place_union_field (record_layout_info rli, tree field) DECL_FIELD_BIT_OFFSET (field) = bitsize_zero_node; SET_DECL_OFFSET_ALIGN (field, BIGGEST_ALIGNMENT); + /* If this is an ERROR_MARK return *after* having set the + field at the start of the union. This helps when parsing + invalid fields. */ + if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK) + return; + /* We assume the union's size will be a multiple of a byte so we don't bother with BITPOS. */ if (TREE_CODE (rli->t) == UNION_TYPE) @@ -823,17 +833,6 @@ place_field (record_layout_info rli, tree field) gcc_assert (TREE_CODE (field) != ERROR_MARK); - if (TREE_CODE (type) == ERROR_MARK) - { - if (TREE_CODE (field) == FIELD_DECL) - { - DECL_FIELD_OFFSET (field) = size_int (0); - DECL_FIELD_BIT_OFFSET (field) = bitsize_int (0); - } - - return; - } - /* If FIELD is static, then treat it like a separate variable, not really like a structure field. If it is a FUNCTION_DECL, it's a method. In both cases, all we do is lay out the decl, and we do @@ -858,6 +857,16 @@ place_field (record_layout_info rli, tree field) return; } + else if (TREE_CODE (type) == ERROR_MARK) + { + /* Place this field at the current allocation position, so we + maintain monotonicity. */ + DECL_FIELD_OFFSET (field) = rli->offset; + DECL_FIELD_BIT_OFFSET (field) = rli->bitpos; + SET_DECL_OFFSET_ALIGN (field, rli->offset_align); + return; + } + /* Work out the known alignment so far. Note that A & (-A) is the value of the least-significant bit in A that is one. */ if (! integer_zerop (rli->bitpos)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e55cee8..b6772a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-04-19 Carlos O'Donell <carlos@codesourcery.com> + + PR c/26774 + * gcc.dg/struct-parse-1.c: New test case. + 2006-04-19 Volker Reichelt <reichelt@igpm.rwth-aachen.de> PR c++/26558 diff --git a/gcc/testsuite/gcc.dg/struct-parse-1.c b/gcc/testsuite/gcc.dg/struct-parse-1.c new file mode 100644 index 0000000..32c1157 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-parse-1.c @@ -0,0 +1,11 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. */ +/* Contributed by Carlos O'Donell on 2006-03-31 */ + +/* This code caused the C frontend to loop + forever exhausting all system memory, or ICE */ +/* Origin: Carlos O'Donell <carlos@codesourcery.com> */ + +/* { dg-options "-std=c99" } */ +struct s { int a; int b; struct t c; }; /* { dg-error "error: field 'c' has incomplete type" } */ +struct s d = { .b = 0 }; + |