re PR c++/88180 (ICE in vec<tree_node*, va_gc, vl_embed>::quick_push(tree_node* const&))

PR c++/88180
	* parser.c (cp_parser_class_specifier_1): If
	cp_parser_check_type_definition fails, skip default arguments, NSDMIs,
	etc. like for erroneous template args.

	* g++.dg/parse/pr88180.C: New test.
	* g++.dg/pr85039-1.C: Don't expect diagnostics inside of the type
	definition's NSDMIs.

From-SVN: r267306
This commit is contained in:
Jakub Jelinek 2018-12-20 18:34:19 +01:00 committed by Jakub Jelinek
parent 50867d20f4
commit 2694cacbc0
5 changed files with 28 additions and 4 deletions

View File

@ -1,5 +1,10 @@
2018-12-20 Jakub Jelinek <jakub@redhat.com>
PR c++/88180
* parser.c (cp_parser_class_specifier_1): If
cp_parser_check_type_definition fails, skip default arguments, NSDMIs,
etc. like for erroneous template args.
* cp-tree.h (cp_fully_fold_init): Declare.
* cp-gimplify.c (cp_fully_fold_init): New function.
* typeck2.c (split_nonconstant_init, store_init_value): Use it

View File

@ -23167,7 +23167,7 @@ cp_parser_class_specifier_1 (cp_parser* parser)
cp_ensure_no_oacc_routine (parser);
/* Issue an error message if type-definitions are forbidden here. */
cp_parser_check_type_definition (parser);
bool type_definition_ok_p = cp_parser_check_type_definition (parser);
/* Remember that we are defining one more class. */
++parser->num_classes_being_defined;
/* Inside the class, surrounding template-parameter-lists do not
@ -23362,7 +23362,7 @@ cp_parser_class_specifier_1 (cp_parser* parser)
cp_default_arg_entry *e;
tree save_ccp, save_ccr;
if (any_erroneous_template_args_p (type))
if (!type_definition_ok_p || any_erroneous_template_args_p (type))
{
/* Skip default arguments, NSDMIs, etc, in order to improve
error recovery (c++/71169, c++/71832). */

View File

@ -1,3 +1,10 @@
2018-12-20 Jakub Jelinek <jakub@redhat.com>
PR c++/88180
* g++.dg/parse/pr88180.C: New test.
* g++.dg/pr85039-1.C: Don't expect diagnostics inside of the type
definition's NSDMIs.
2018-12-20 Richard Sandiford <richard.sandiford@arm.com>
* gcc.target/aarch64/pr64946.c: Force nosve.

View File

@ -0,0 +1,12 @@
// PR c++/88180
// { dg-do compile }
// { dg-options "--param ggc-min-heapsize=1024" }
struct d {
static d *b;
} * d::b(__builtin_offsetof(struct { // { dg-error "types may not be defined" }
int i;
struct a { // { dg-error "types may not be defined" }
int c() { return .1f; }
};
}, i));

View File

@ -5,9 +5,9 @@ constexpr int a() {
__builtin_offsetof(struct { // { dg-error "types may not be defined" }
int i;
short b {
__builtin_offsetof(struct { // { dg-error "types may not be defined" }
__builtin_offsetof(struct {
int j;
struct c { // { dg-error "types may not be defined" }
struct c {
void d() {
}
};