re PR c++/27820 (ICE with duplicate label)

PR c++/27820
	* decl.c (define_label): Return error_mark_node on error.
	* semantics.c (finish_label_stmt): Don't call
	add_stmt for invalid labels.

	* g++.dg/other/label1.C: New test.


Co-Authored-By: Andrew Pinski <pinskia@gmail.com>

From-SVN: r115265
This commit is contained in:
Lee Millward 2006-07-07 17:57:12 +00:00 committed by Lee Millward
parent bfabddb6c0
commit 417fa55ba5
5 changed files with 28 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2006-06-29 Lee Millward <lee.millward@gmail.com>
Andrew Pinski <pinskia@gmail.com>
PR c++/27820
* decl.c (define_label): Return error_mark_node on error.
* semantics.c (finish_label_stmt): Don't call
add_stmt for invalid labels.
2006-07-06 Jason Merrill <jason@redhat.com>
PR c++/28279

View File

@ -2543,7 +2543,10 @@ define_label (location_t location, tree name)
pedwarn ("label named wchar_t");
if (DECL_INITIAL (decl) != NULL_TREE)
error ("duplicate label %qD", decl);
{
error ("duplicate label %qD", decl);
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
else
{
struct named_label_use_entry *use;

View File

@ -1293,6 +1293,10 @@ tree
finish_label_stmt (tree name)
{
tree decl = define_label (input_location, name);
if (decl == error_mark_node)
return error_mark_node;
return add_stmt (build_stmt (LABEL_EXPR, decl));
}

View File

@ -1,3 +1,8 @@
2006-07-07 Lee Millward <lee.millward@gmail.com>
PR c++/27820
* g++.dg/other/label1.C: New test.
2006-07-07 Richard Guenther <rguenther@suse.de>
PR middle-end/28268

View File

@ -0,0 +1,7 @@
//PR c++/27820
void foo()
{
L: L: ; // { dg-error "duplicate label" }
}