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
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
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). */
+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.
--- /dev/null
+// 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));
__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() {
}
};