From: Marek Polacek Date: Thu, 21 Nov 2019 15:27:46 +0000 (+0000) Subject: PR c++/92450 - ICE with invalid nested name specifier. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=523cfd52a29d496a5c0445e5307e9ffc05242b20;p=gcc.git 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. * g++.dg/parse/crash71.C: New test. From-SVN: r278570 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 507741bf2ff..cd1cd17ca4a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-11-21 Marek Polacek + + 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 Jason Merrill diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 03b1ec748c7..be3128634b1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af77dfa7c2b..b4a961937ba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-21 Marek Polacek + + PR c++/92450 - ICE with invalid nested name specifier. + * g++.dg/parse/crash71.C: New test. + 2019-11-21 Wilco Dijkstra * 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 index 00000000000..13f484801fe --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash71.C @@ -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 "" } +};