aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2016-03-31 15:30:33 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2016-03-31 15:30:33 +0000
commit88504f3435845976b92ee7e9d358f8e687502772 (patch)
tree6129d53eb107465f19b3b61d2bbcc066a80e270f /gcc/varasm.c
parent95d34b9618011fea39c48544cc8937577720dcc1 (diff)
downloadgcc-88504f3435845976b92ee7e9d358f8e687502772.zip
gcc-88504f3435845976b92ee7e9d358f8e687502772.tar.gz
gcc-88504f3435845976b92ee7e9d358f8e687502772.tar.bz2
re PR c++/70393 (Miscompilation: missing constructor call for static object)
PR c++/70393 * varasm.c (output_constructor_regular_field): Flush bitfield earlier. Assert we don't want to move backwards. cp/ * constexpr.c (cxx_eval_store_expression): Keep CONSTRUCTOR elements in field order. testsuite/ * g++.dg/cpp0x/constexpr-virtual6.C: New. From-SVN: r234636
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 3a3573e..b0f2af0 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -4929,6 +4929,14 @@ output_constructor_regular_field (oc_local_state *local)
unsigned int align2;
+ /* Output any buffered-up bit-fields preceding this element. */
+ if (local->byte_buffer_in_use)
+ {
+ assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
+ local->total_bytes++;
+ local->byte_buffer_in_use = false;
+ }
+
if (local->index != NULL_TREE)
{
/* Perform the index calculation in modulo arithmetic but
@@ -4945,22 +4953,19 @@ output_constructor_regular_field (oc_local_state *local)
else
fieldpos = 0;
- /* Output any buffered-up bit-fields preceding this element. */
- if (local->byte_buffer_in_use)
- {
- assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
- local->total_bytes++;
- local->byte_buffer_in_use = false;
- }
-
/* Advance to offset of this element.
Note no alignment needed in an array, since that is guaranteed
if each element has the proper size. */
- if ((local->field != NULL_TREE || local->index != NULL_TREE)
- && fieldpos > local->total_bytes)
+ if (local->field != NULL_TREE || local->index != NULL_TREE)
{
- assemble_zeros (fieldpos - local->total_bytes);
- local->total_bytes = fieldpos;
+ if (fieldpos > local->total_bytes)
+ {
+ assemble_zeros (fieldpos - local->total_bytes);
+ local->total_bytes = fieldpos;
+ }
+ else
+ /* Must not go backwards. */
+ gcc_assert (fieldpos == local->total_bytes);
}
/* Find the alignment of this element. */