diff options
author | Martin Sebor <msebor@redhat.com> | 2018-01-16 03:02:34 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-01-15 20:02:34 -0700 |
commit | 66a366a05a39ce91597fe192e3d943efd810eb87 (patch) | |
tree | 599e77f067058b423653166196bcfc9d07867f25 | |
parent | 75a3c61ae44b7820baf7946c3ddf3632adedcccf (diff) | |
download | gcc-66a366a05a39ce91597fe192e3d943efd810eb87.zip gcc-66a366a05a39ce91597fe192e3d943efd810eb87.tar.gz gcc-66a366a05a39ce91597fe192e3d943efd810eb87.tar.bz2 |
PR c++/83588 - struct with two flexible arrays causes an internal compiler error
gcc/cp/ChangeLog:
PR c++/83588
* class.c (find_flexarrays): Make a record of multiple flexible array
members.
gcc/testsuite/ChangeLog:
PR c++/83588
* g++.dg/ext/flexary28.C: New test.
From-SVN: r256721
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/flexary28.C | 46 |
4 files changed, 62 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 533e2d3..7e437f8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-01-15 Martin Sebor <msebor@redhat.com> + + PR c++/83588 + * class.c (find_flexarrays): Make a record of multiple flexible array + members. + 2018-01-12 Jason Merrill <jason@redhat.com> PR c++/83186 - ICE with static_cast of list-initialized temporary. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 985b443..4103630 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6566,14 +6566,17 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p, /* Flexible array members have no upper bound. */ if (fmem->array) { - /* Replace the zero-length array if it's been stored and - reset the after pointer. */ if (TYPE_DOMAIN (TREE_TYPE (fmem->array))) { + /* Replace the zero-length array if it's been stored and + reset the after pointer. */ fmem->after[bool (pun)] = NULL_TREE; fmem->array = fld; fmem->enclosing = pstr; } + else if (!fmem->after[bool (pun)]) + /* Make a record of another flexible array member. */ + fmem->after[bool (pun)] = fld; } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2933f83..b29c659 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-15 Martin Sebor <msebor@redhat.com> + + PR c++/83588 + * g++.dg/ext/flexary28.C: New test. + 2018-01-15 Louis Krupp <louis.krupp@zoho.com> PR fortran/82257 diff --git a/gcc/testsuite/g++.dg/ext/flexary28.C b/gcc/testsuite/g++.dg/ext/flexary28.C new file mode 100644 index 0000000..68172c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary28.C @@ -0,0 +1,46 @@ +// PR c++/83588 - struct with two flexible arrays causes an internal compiler +// error +// { dg-do compile } +// { dg-options "-Wno-pedantic" } + +struct A { + int i; + int a[]; // { dg-error "flexible array member .A::a. not at end of .struct A." } + int b[]; +}; + +struct B { + int i; + int a[]; // { dg-error "flexible array member .B::a. not at end of .struct B." } + int j; + int b[][2]; +}; + +struct C { + int i; + struct { + int a[]; // { dg-error "flexible array member .C::<unnamed struct>::a. not at end of .struct C." } + }; + int b[]; +}; + +struct D { + int i; + struct { + int a[]; // { dg-error "flexible array member .D::<unnamed struct>::a. not at end of .struct D." } + } b[]; + int c[]; +}; + +struct E { + int i; + int a[0]; + int b[]; // { dg-error "flexible array member .E::b. not at end of .struct E." } + int d[]; +}; + +struct F { + int i; + int a[]; // { dg-error "flexible array member .F::a. not at end of .struct F." } + int b[], c[], d[]; +}; |