From 2694cacbc0929f8f2e503bef1ddaf1a3ac5c81b0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 20 Dec 2018 18:34:19 +0100 Subject: [PATCH] re PR c++/88180 (ICE in vec::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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 4 ++-- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/g++.dg/parse/pr88180.C | 12 ++++++++++++ gcc/testsuite/g++.dg/pr85039-1.C | 4 ++-- 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/pr88180.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c1b7bba48e9..7680b549c27 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2018-12-20 Jakub Jelinek + 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 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d6bac826581..2cd91a37031 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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). */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cfdd7bb204..bfc24420ed3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-12-20 Jakub Jelinek + + 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 * gcc.target/aarch64/pr64946.c: Force nosve. diff --git a/gcc/testsuite/g++.dg/parse/pr88180.C b/gcc/testsuite/g++.dg/parse/pr88180.C new file mode 100644 index 00000000000..1d5975026c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr88180.C @@ -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)); diff --git a/gcc/testsuite/g++.dg/pr85039-1.C b/gcc/testsuite/g++.dg/pr85039-1.C index f57c8a261de..2bda81ba839 100644 --- a/gcc/testsuite/g++.dg/pr85039-1.C +++ b/gcc/testsuite/g++.dg/pr85039-1.C @@ -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() { } }; -- 2.30.2