Commit 71b6cb2b by Jakub Jelinek Committed by Jakub Jelinek

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
parent 4556c5b3
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> 2019-03-06 Jason Merrill <jason@redhat.com>
PR c++/89576 - if constexpr of lambda capture. PR c++/89576 - if constexpr of lambda capture.
......
...@@ -419,6 +419,15 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) ...@@ -419,6 +419,15 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
if (ftype == error_mark_node) if (ftype == error_mark_node)
continue; 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 /* We could skip vfields and fields of types with
user-defined constructors, but I think that won't improve user-defined constructors, but I think that won't improve
performance at all; it should be simpler in general just performance at all; it should be simpler in general just
......
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> 2019-03-06 Peter Bergner <bergner@linux.ibm.com>
PR rtl-optimization/88845 PR rtl-optimization/88845
......
// 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 (); }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment