Commit 9113b9fb by Nathan Froyd Committed by Nathan Froyd

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
parent c70c0342
2011-02-23 Nathan Froyd <froydnj@codesourcery.com>
PR c++/46868
* parser.c (cp_parser_class_specifier): Require a closing brace
to attempt error recovery.
2011-02-23 Jakub Jelinek <jakub@redhat.com> 2011-02-23 Jakub Jelinek <jakub@redhat.com>
PR c++/47833 PR c++/47833
......
...@@ -16874,6 +16874,7 @@ cp_parser_class_specifier (cp_parser* parser) ...@@ -16874,6 +16874,7 @@ cp_parser_class_specifier (cp_parser* parser)
tree old_scope = NULL_TREE; tree old_scope = NULL_TREE;
tree scope = NULL_TREE; tree scope = NULL_TREE;
tree bases; tree bases;
cp_token *closing_brace;
push_deferring_access_checks (dk_no_deferred); push_deferring_access_checks (dk_no_deferred);
...@@ -16943,7 +16944,7 @@ cp_parser_class_specifier (cp_parser* parser) ...@@ -16943,7 +16944,7 @@ cp_parser_class_specifier (cp_parser* parser)
cp_parser_member_specification_opt (parser); cp_parser_member_specification_opt (parser);
/* Look for the trailing `}'. */ /* 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. */ /* Look for trailing attributes to apply to this class. */
if (cp_parser_allow_gnu_extensions_p (parser)) if (cp_parser_allow_gnu_extensions_p (parser))
attributes = cp_parser_attributes_opt (parser); attributes = cp_parser_attributes_opt (parser);
...@@ -17018,8 +17019,9 @@ cp_parser_class_specifier (cp_parser* 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 /* If we don't have a type, then something is very wrong and we
shouldn't try to do anything clever. */ shouldn't try to do anything clever. Likewise for not seeing the
if (TYPE_P (type) && want_semicolon) closing brace. */
if (closing_brace && TYPE_P (type) && want_semicolon)
{ {
cp_token_position prev cp_token_position prev
= cp_lexer_previous_token_position (parser->lexer); = cp_lexer_previous_token_position (parser->lexer);
......
2011-02-23 Nathan Froyd <froydnj@codesourcery.com>
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 <rguenther@suse.de> 2011-02-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47838 PR tree-optimization/47838
......
...@@ -21,6 +21,6 @@ struct X ...@@ -21,6 +21,6 @@ struct X
}; // { dg-error "2:expected '.' at end of input" "at end of input" } }; // { 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 "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 } // { dg-error "1:expected ';' before '.' token" "function" { target *-*-* } 22 }
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// Origin: Robert Schiele; PR C++/8799 // Origin: Robert Schiele; PR C++/8799
// { dg-do compile } // { dg-do compile }
struct { // { dg-error "" } struct {
a(void = 0; a(0), a(0) // { dg-error "" "" { target *-*-* } } a(void = 0; a(0), a(0) // { dg-error "" "" { target *-*-* } }
// PR c++/46868
// { dg-do compile }
template < int > struct S { S < // { dg-error "" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment