Commit a232a1cb by Marek Polacek Committed by Marek Polacek

re PR c++/79535 (ICE in verify_ctor_sanity, at cp/constexpr.c:2636)

	PR c++/79535
	* cp-tree.h (maybe_reject_flexarray_init): Declare.
	* init.c (maybe_reject_flexarray_init): No longer static.
	Add check for current_function_decl.
	* parser.c (cp_parser_late_parse_one_default_arg): Reject
	a default mem-initializer for a flexible array.

	* g++.dg/ext/flexary23.C: New test.

From-SVN: r245641
parent a2b48844
2017-02-21 Marek Polacek <polacek@redhat.com>
PR c++/79535
* cp-tree.h (maybe_reject_flexarray_init): Declare.
* init.c (maybe_reject_flexarray_init): No longer static.
Add check for current_function_decl.
* parser.c (cp_parser_late_parse_one_default_arg): Reject
a default mem-initializer for a flexible array.
2017-02-21 Jakub Jelinek <jakub@redhat.com>
Paolo Carlini <paolo.carlini@oracle.com>
......
......@@ -6069,6 +6069,7 @@ extern tree scalar_constant_value (tree);
extern tree decl_really_constant_value (tree);
extern int diagnose_uninitialized_cst_or_ref_member (tree, bool, bool);
extern tree build_vtbl_address (tree);
extern bool maybe_reject_flexarray_init (tree, tree);
/* in lex.c */
extern void cxx_dup_lang_specific_decl (tree);
......
......@@ -600,7 +600,7 @@ get_nsdmi (tree member, bool in_ctor)
/* Diagnose the flexible array MEMBER if its INITializer is non-null
and return true if so. Otherwise return false. */
static bool
bool
maybe_reject_flexarray_init (tree member, tree init)
{
tree type = TREE_TYPE (member);
......@@ -615,6 +615,7 @@ maybe_reject_flexarray_init (tree member, tree init)
initializer list. */
location_t loc;
if (DECL_INITIAL (member) == init
|| !current_function_decl
|| DECL_DEFAULTED_FN (current_function_decl))
loc = DECL_SOURCE_LOCATION (member);
else
......
......@@ -27228,6 +27228,8 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
if (TREE_CODE (decl) == PARM_DECL)
parsed_arg = check_default_argument (parmtype, parsed_arg,
tf_warning_or_error);
else if (maybe_reject_flexarray_init (decl, parsed_arg))
parsed_arg = error_mark_node;
else
parsed_arg = digest_nsdmi_init (decl, parsed_arg);
}
2017-02-21 Marek Polacek <polacek@redhat.com>
PR c++/79535
* g++.dg/ext/flexary23.C: New test.
2017-02-21 Jakub Jelinek <jakub@redhat.com>
PR c++/79654
......
// PR c++/79535 - ICE with NSDMI and array
// { dg-do compile { target c++14 } }
// { dg-options -Wno-pedantic }
struct A
{
int b = 1;
int c = 2;
int x[] = { c, 3 }; // { dg-error "initializer for flexible array member" }
};
A a = { 4, 5 };
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