re PR c/43384 (ICE: Segmentation fault with invalid K&R-like code)

gcc/

2010-11-16  Simon Martin  <simartin@users.sourceforge.net>

	PR c/43384
	* c-decl.c (lookup_label): Labels can only be referenced in a
	function's scope. 
	(store_parm_decls_oldstyle): Skip erroneous parameters.

gcc/testsuite/
 
2010-11-16  Simon Martin  <simartin@users.sourceforge.net>

	PR c/43384
	* gcc.dg/parser-error-3.c: New test.

From-SVN: r166408
This commit is contained in:
Simon Martin 2010-11-06 21:58:50 +00:00 committed by Simon Martin
parent da0dc81873
commit c58e98c83b
4 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2010-11-06 Simon Martin <simartin@users.sourceforge.net>
PR c/43384
* c-decl.c (lookup_label): Labels can only be referenced in a
function's scope.
(store_parm_decls_oldstyle): Skip erroneous parameters.
2010-11-06 Anatoly Sokolov <aesok@post.ru>
* config/fr30/fr30.h (FUNCTION_VALUE_REGNO_P, FUNCTION_VALUE,

View File

@ -3013,7 +3013,7 @@ lookup_label (tree name)
tree label;
struct c_label_vars *label_vars;
if (current_function_decl == 0)
if (current_function_scope == 0)
{
error ("label %qE referenced outside of any function", name);
return 0;
@ -7847,6 +7847,9 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
if (b && B_IN_CURRENT_SCOPE (b))
{
decl = b->decl;
/* Skip erroneous parameters. */
if (decl == error_mark_node)
continue;
/* If we got something other than a PARM_DECL it is an error. */
if (TREE_CODE (decl) != PARM_DECL)
error_at (DECL_SOURCE_LOCATION (decl),

View File

@ -1,3 +1,8 @@
2010-11-06 Simon Martin <simartin@users.sourceforge.net>
PR c/43384
* gcc.dg/parser-error-3.c: New test.
2010-11-06 Nathan Froyd <froydnj@codesourcery.com>
PR c++/45332

View File

@ -0,0 +1,14 @@
/* PR c/43384 */
/* { dg-do "compile" } */
void c_direct(par)
void *par = &&lab; /* { dg-error "is initialized|non-standard|outside of" } */
{}
void foo(p, q)
int *p = &q; /* { dg-error "initialized|undeclared" } */
{}
void bar(i)
int j = i; /* { dg-error "initialized|undeclared|no such parameter" } */
{}