re PR c++/88180 (ICE in vec<tree_node*, va_gc, vl_embed>::quick_push(tree_node* const&))
authorJakub Jelinek <jakub@redhat.com>
Thu, 20 Dec 2018 17:34:19 +0000 (18:34 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 20 Dec 2018 17:34:19 +0000 (18:34 +0100)
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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/pr88180.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pr85039-1.C

index c1b7bba..7680b54 100644 (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
index d6bac82..2cd91a3 100644 (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).  */
index 2cfdd7b..bfc2442 100644 (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.
diff --git a/gcc/testsuite/g++.dg/parse/pr88180.C b/gcc/testsuite/g++.dg/parse/pr88180.C
new file mode 100644 (file)
index 0000000..1d59750
--- /dev/null
@@ -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));
index f57c8a2..2bda81b 100644 (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() {
           }
         };