From: Nathan Froyd Date: Wed, 23 Feb 2011 16:44:18 +0000 (+0000) Subject: re PR c++/46868 (ICE: SIGSEGV splay_tree_splay (splay-tree.c:149) on invalid code) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9113b9fb6d0a11590e479d694552782310703902;p=gcc.git re PR c++/46868 (ICE: SIGSEGV splay_tree_splay (splay-tree.c:149) on invalid code) fix PR c++/46868 gcc/cp/ PR c++/46868 * parser.c (cp_parser_class_specifier): Require a closing brace to attempt error recovery. gcc/testsuite/ PR c++/46868 * g++.dg/pr46868.C: New test. * g++.dg/parse/parameter-declaration-1.C: Adjust. * g++.dg/parse/error14.C: Adjust. From-SVN: r170440 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0e647f82a67..195b3192bf9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-02-23 Nathan Froyd + + PR c++/46868 + * parser.c (cp_parser_class_specifier): Require a closing brace + to attempt error recovery. + 2011-02-23 Jakub Jelinek PR c++/47833 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8f4a1219a73..5b08389f4e7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -16874,6 +16874,7 @@ cp_parser_class_specifier (cp_parser* parser) tree old_scope = NULL_TREE; tree scope = NULL_TREE; tree bases; + cp_token *closing_brace; push_deferring_access_checks (dk_no_deferred); @@ -16943,7 +16944,7 @@ cp_parser_class_specifier (cp_parser* parser) cp_parser_member_specification_opt (parser); /* Look for the trailing `}'. */ - cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE); + closing_brace = cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE); /* Look for trailing attributes to apply to this class. */ if (cp_parser_allow_gnu_extensions_p (parser)) attributes = cp_parser_attributes_opt (parser); @@ -17018,8 +17019,9 @@ cp_parser_class_specifier (cp_parser* parser) } /* If we don't have a type, then something is very wrong and we - shouldn't try to do anything clever. */ - if (TYPE_P (type) && want_semicolon) + shouldn't try to do anything clever. Likewise for not seeing the + closing brace. */ + if (closing_brace && TYPE_P (type) && want_semicolon) { cp_token_position prev = cp_lexer_previous_token_position (parser->lexer); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f92d25e12cd..20e9eed34ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-02-23 Nathan Froyd + + PR c++/46868 + * g++.dg/pr46868.C: New test. + * g++.dg/parse/parameter-declaration-1.C: Adjust. + * g++.dg/parse/error14.C: Adjust. + 2011-02-23 Richard Guenther PR tree-optimization/47838 diff --git a/gcc/testsuite/g++.dg/parse/error14.C b/gcc/testsuite/g++.dg/parse/error14.C index 37abe37562a..04f2f56b6dc 100644 --- a/gcc/testsuite/g++.dg/parse/error14.C +++ b/gcc/testsuite/g++.dg/parse/error14.C @@ -21,6 +21,6 @@ struct X }; // { dg-error "2:expected '.' at end of input" "at end of input" } // { dg-error "1:expected primary-expression before '.' token" "primary" { target *-*-* } 22 } - // { dg-error "2:expected ';' after struct definition" "semicolon" { target *-*-* } 22 } + // { dg-error "1:expected unqualified-id" "unqualified-id" { target *-*-* } 22 } // { dg-error "1:expected ';' before '.' token" "function" { target *-*-* } 22 } diff --git a/gcc/testsuite/g++.dg/parse/parameter-declaration-1.C b/gcc/testsuite/g++.dg/parse/parameter-declaration-1.C index 58f679944e2..22d6f214d7d 100644 --- a/gcc/testsuite/g++.dg/parse/parameter-declaration-1.C +++ b/gcc/testsuite/g++.dg/parse/parameter-declaration-1.C @@ -2,5 +2,5 @@ // Origin: Robert Schiele; PR C++/8799 // { dg-do compile } -struct { // { dg-error "" } +struct { a(void = 0; a(0), a(0) // { dg-error "" "" { target *-*-* } } diff --git a/gcc/testsuite/g++.dg/pr46868.C b/gcc/testsuite/g++.dg/pr46868.C new file mode 100644 index 00000000000..544c7b219df --- /dev/null +++ b/gcc/testsuite/g++.dg/pr46868.C @@ -0,0 +1,4 @@ +// PR c++/46868 +// { dg-do compile } + +template < int > struct S { S < // { dg-error "" }