summaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2016-12-14 20:41:43 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2016-12-14 20:41:43 +0000
commit5ccc4c372e5d625454a5939ce3f741486d490f30 (patch)
treef6f66a11d2a821e98fa7c953cadb8f50678c0dff /gcc/cp/init.c
parent47f6959b66fcda20708399fdf6d5d8889a8528ea (diff)
downloadgcc-5ccc4c372e5d625454a5939ce3f741486d490f30.tar.gz
PR c++/72775
* init.c (perform_member_init): Diagnose member initializer for flexible array member. * g++.dg/ext/flexary12.C: Adjust dg-error. * g++.dg/ext/flexary20.C: New. * g++.dg/ext/flexary21.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243669 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index b4b6cdb0a4c..47428b96f3d 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -800,6 +800,14 @@ perform_member_init (tree member, tree init)
in that case. */
init = build_x_compound_expr_from_list (init, ELK_MEM_INIT,
tf_warning_or_error);
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE
+ && init != NULL_TREE)
+ {
+ error_at (DECL_SOURCE_LOCATION (current_function_decl),
+ "member initializer for flexible array member");
+ inform (DECL_SOURCE_LOCATION (member), "%q#D initialized", member);
+ }
if (init)
finish_expr_stmt (cp_build_modify_expr (input_location, decl,