Skip to content

Commit 4297999

Browse files
author
msebor
committed
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256721 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 2e5c1c5 commit 4297999

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

gcc/cp/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2018-01-15 Martin Sebor <[email protected]>
2+
3+
PR c++/83588
4+
* class.c (find_flexarrays): Make a record of multiple flexible array
5+
members.
6+
17
2018-01-12 Jason Merrill <[email protected]>
28

39
PR c++/83186 - ICE with static_cast of list-initialized temporary.

gcc/cp/class.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6566,14 +6566,17 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
65666566
/* Flexible array members have no upper bound. */
65676567
if (fmem->array)
65686568
{
6569-
/* Replace the zero-length array if it's been stored and
6570-
reset the after pointer. */
65716569
if (TYPE_DOMAIN (TREE_TYPE (fmem->array)))
65726570
{
6571+
/* Replace the zero-length array if it's been stored and
6572+
reset the after pointer. */
65736573
fmem->after[bool (pun)] = NULL_TREE;
65746574
fmem->array = fld;
65756575
fmem->enclosing = pstr;
65766576
}
6577+
else if (!fmem->after[bool (pun)])
6578+
/* Make a record of another flexible array member. */
6579+
fmem->after[bool (pun)] = fld;
65776580
}
65786581
else
65796582
{

gcc/testsuite/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2018-01-15 Martin Sebor <[email protected]>
2+
3+
PR c++/83588
4+
* g++.dg/ext/flexary28.C: New test.
5+
16
2018-01-15 Louis Krupp <[email protected]>
27

38
PR fortran/82257
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// PR c++/83588 - struct with two flexible arrays causes an internal compiler
2+
// error
3+
// { dg-do compile }
4+
// { dg-options "-Wno-pedantic" }
5+
6+
struct A {
7+
int i;
8+
int a[]; // { dg-error "flexible array member .A::a. not at end of .struct A." }
9+
int b[];
10+
};
11+
12+
struct B {
13+
int i;
14+
int a[]; // { dg-error "flexible array member .B::a. not at end of .struct B." }
15+
int j;
16+
int b[][2];
17+
};
18+
19+
struct C {
20+
int i;
21+
struct {
22+
int a[]; // { dg-error "flexible array member .C::<unnamed struct>::a. not at end of .struct C." }
23+
};
24+
int b[];
25+
};
26+
27+
struct D {
28+
int i;
29+
struct {
30+
int a[]; // { dg-error "flexible array member .D::<unnamed struct>::a. not at end of .struct D." }
31+
} b[];
32+
int c[];
33+
};
34+
35+
struct E {
36+
int i;
37+
int a[0];
38+
int b[]; // { dg-error "flexible array member .E::b. not at end of .struct E." }
39+
int d[];
40+
};
41+
42+
struct F {
43+
int i;
44+
int a[]; // { dg-error "flexible array member .F::a. not at end of .struct F." }
45+
int b[], c[], d[];
46+
};

0 commit comments

Comments
 (0)