diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-03-06 19:46:32 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-03-06 19:46:32 +0100 |
commit | 71b6cb2bbccba8922a8c7e9082a13a02dee7e57d (patch) | |
tree | 0ab09c800fdc1e4086296c067ed4ccf46b89414c | |
parent | 4556c5b3157f496c73f7fcd25d103ad3e6ff1874 (diff) | |
download | gcc-71b6cb2bbccba8922a8c7e9082a13a02dee7e57d.zip gcc-71b6cb2bbccba8922a8c7e9082a13a02dee7e57d.tar.gz gcc-71b6cb2bbccba8922a8c7e9082a13a02dee7e57d.tar.bz2 |
re PR c++/87148 (backward compatibility issue to take char [] as incomplete type)
PR c++/87148
* init.c (build_value_init_noctor): Ignore flexible array members.
* g++.dg/ext/flexary34.C: New test.
From-SVN: r269434
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/init.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/flexary34.C | 10 |
4 files changed, 29 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a076fa9..b0c1f88 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-03-06 Jakub Jelinek <jakub@redhat.com> + + PR c++/87148 + * init.c (build_value_init_noctor): Ignore flexible array members. + 2019-03-06 Jason Merrill <jason@redhat.com> PR c++/89576 - if constexpr of lambda capture. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index eb3b504..79a93a2 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -419,6 +419,15 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) if (ftype == error_mark_node) continue; + /* Ignore flexible array members for value initialization. */ + if (TREE_CODE (ftype) == ARRAY_TYPE + && !COMPLETE_TYPE_P (ftype) + && !TYPE_DOMAIN (ftype) + && COMPLETE_TYPE_P (TREE_TYPE (ftype)) + && (next_initializable_field (DECL_CHAIN (field)) + == NULL_TREE)) + continue; + /* We could skip vfields and fields of types with user-defined constructors, but I think that won't improve performance at all; it should be simpler in general just diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9a65e3a..4175bc4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-06 Jakub Jelinek <jakub@redhat.com> + + PR c++/87148 + * g++.dg/ext/flexary34.C: New test. + 2019-03-06 Peter Bergner <bergner@linux.ibm.com> PR rtl-optimization/88845 diff --git a/gcc/testsuite/g++.dg/ext/flexary34.C b/gcc/testsuite/g++.dg/ext/flexary34.C new file mode 100644 index 0000000..bbbbf85 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary34.C @@ -0,0 +1,10 @@ +// PR c++/87148 +// { dg-do compile } +// { dg-options "-pedantic" } + +struct Tst { int i; char t[]; }; // { dg-warning "forbids flexible array member" } + +Tst t {}; // { dg-warning "extended initializer lists only available with" "" { target c++98_only } } +Tst u = Tst(); +void foo () { Tst u = {}; } +Tst *bar () { return new Tst (); } |