PR c++/92450 - ICE with invalid nested name specifier.
authorMarek Polacek <polacek@redhat.com>
Thu, 21 Nov 2019 15:27:46 +0000 (15:27 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 21 Nov 2019 15:27:46 +0000 (15:27 +0000)
* parser.c (cp_parser_member_declaration): Don't attempt to print
erroneous bit-field diagnostic if grokdeclarator returns
error_mark_node.

* g++.dg/parse/crash71.C: New test.

From-SVN: r278570

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash71.C [new file with mode: 0644]

index 507741bf2ffa02b8ed0c2566bb51660fb1534325..cd1cd17ca4acc201de7a88c09044f6a5cc839182 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-21  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/92450 - ICE with invalid nested name specifier.
+       * parser.c (cp_parser_member_declaration): Don't attempt to print
+       erroneous bit-field diagnostic if grokdeclarator returns
+       error_mark_node.
+
 2019-11-21  Jakub Jelinek  <jakub@redhat.com>
            Jason Merrill  <jason@redhat.com>
 
index 03b1ec748c797a1f2f6a505ff1d6564935aeb813..be3128634b1f7a676ee9fa4a959fb0ddfdec2c23 100644 (file)
@@ -25062,9 +25062,10 @@ cp_parser_member_declaration (cp_parser* parser)
                  tree d = grokdeclarator (declarator, &decl_specifiers,
                                           BITFIELD, /*initialized=*/false,
                                           &attributes);
-                 error_at (DECL_SOURCE_LOCATION (d),
-                           "bit-field %qD has non-integral type %qT",
-                           d, TREE_TYPE (d));
+                 if (!error_operand_p (d))
+                   error_at (DECL_SOURCE_LOCATION (d),
+                             "bit-field %qD has non-integral type %qT",
+                             d, TREE_TYPE (d));
                  cp_parser_skip_to_end_of_statement (parser);
                  /* Avoid "extra ;" pedwarns.  */
                  if (cp_lexer_next_token_is (parser->lexer,
index af77dfa7c2bd549e9d7f1853d9041186ae4bae8e..b4a961937baa943e69864d7965289907c6a4c4ac 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-21  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/92450 - ICE with invalid nested name specifier.
+       * g++.dg/parse/crash71.C: New test.
+
 2019-11-21  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * gfortran.dg/global_vars_f90_init_driver.c: Add missing extern.
diff --git a/gcc/testsuite/g++.dg/parse/crash71.C b/gcc/testsuite/g++.dg/parse/crash71.C
new file mode 100644 (file)
index 0000000..13f4848
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/92450 - ICE with invalid nested name specifier.
+
+typedef int C2;
+struct B1 {
+  struct B2 {
+  };
+};
+
+struct S6g {
+  C2 : B1:B2; // { dg-error "" }
+};