re PR c/14734 (Error recovery problem with undeclared array bounds)

* c-decl.c: Verify that C_SIZEOF_STRUCT_LANG_IDENTIFIER is correct.
	(struct c_binding, struct c_scope): Add chain_next
	attributes to GTY markers.
	(struct lang_identifier, struct lang_tree_node): Define
	here...
	* c-tree.h: ... not here.  No longer need to declare struct
	c_binding either.  Do define C_SIZEOF_STRUCT_LANG_IDENTIFIER.
	* c-lang.c, objc/objc-lang.c: Set LANG_HOOKS_IDENTIFIER_SIZE
	to C_SIZEOF_STRUCT_LANG_IDENTIFIER.

	PR 14734, 11944
	* c-decl.c (get_parm_info): If error_mark_node is encountered
	in the bindings chain, unbind and discard it; don't abort.
	* testsuite/gcc.dg/noncompile/undeclared-2.c: New test.

From-SVN: r80042
This commit is contained in:
Zack Weinberg 2004-03-28 17:45:57 +00:00
parent f26e5597f0
commit 18d5f9820c
7 changed files with 78 additions and 44 deletions

View File

@ -1,8 +1,24 @@
2004-03-28 Olga Golovonevsky <olga@il.ibm.com>
Dorit Naishlos <dorit@il.ibm.com>
2004-03-28 Zack Weinberg <zack@codesourcery.com>
* config/rs6000/altivec.md: (andvv16qi3, andv8hi3, one_cmplv16qi2,
one_cmplv8hi2, one_cmplv4si2, iorv16qi3, iorv8hi3,): New modelling.
* c-decl.c: Verify that C_SIZEOF_STRUCT_LANG_IDENTIFIER is correct.
(struct c_binding, struct c_scope): Add chain_next
attributes to GTY markers.
(struct lang_identifier, struct lang_tree_node): Define
here...
* c-tree.h: ... not here. No longer need to declare struct
c_binding either. Do define C_SIZEOF_STRUCT_LANG_IDENTIFIER.
* c-lang.c, objc/objc-lang.c: Set LANG_HOOKS_IDENTIFIER_SIZE
to C_SIZEOF_STRUCT_LANG_IDENTIFIER.
PR 14734, 11944
* c-decl.c (get_parm_info): If error_mark_node is encountered
in the bindings chain, unbind and discard it; don't abort.
2004-03-28 Olga Golovonevsky <olga@il.ibm.com>
Dorit Naishlos <dorit@il.ibm.com>
* config/rs6000/altivec.md: (andvv16qi3, andv8hi3, one_cmplv16qi2,
one_cmplv8hi2, one_cmplv4si2, iorv16qi3, iorv8hi3,): New modelling.
2004-03-28 Stephane Carrez <stcarrez@nerim.fr>
@ -63,10 +79,10 @@
with TYPE_ORIG_SIZE_TYPE.
2004-03-25 Aldy Hernandez <aldyh@redhat.com>
PR 14219
* c-typeck.c (build_binary_op): Do not allow comparisons of
vectors.
PR 14219
* c-typeck.c (build_binary_op): Do not allow comparisons of
vectors.
2004-03-26 James A. Morrison <ja2morri@uwaterloo.ca>
@ -90,8 +106,8 @@
2004-03-25 Richard Henderson <rth@redhat.com>
PR 11527
* c-typeck.c (pop_init_level): Emit pending init elements earlier
rather than later.
* c-typeck.c (pop_init_level): Emit pending init elements earlier
rather than later.
2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

View File

@ -160,7 +160,7 @@ bool c_override_global_bindings_to_false;
suppress further errors about that identifier in the current
function. */
struct c_binding GTY(())
struct c_binding GTY((chain_next ("%h.prev")))
{
tree decl; /* the decl bound */
tree id; /* the identifier it's bound to */
@ -184,6 +184,34 @@ struct c_binding GTY(())
#define I_LABEL_DECL(node) \
(I_LABEL_BINDING(node) ? I_LABEL_BINDING(node)->decl : 0)
/* Each C symbol points to three linked lists of c_binding structures.
These describe the values of the identifier in the three different
namespaces defined by the language. */
struct lang_identifier GTY(())
{
struct c_common_identifier common_id;
struct c_binding *symbol_binding; /* vars, funcs, constants, typedefs */
struct c_binding *tag_binding; /* struct/union/enum tags */
struct c_binding *label_binding; /* labels */
};
/* Validate c-lang.c's assumptions. */
extern char C_SIZEOF_STRUCT_LANG_IDENTIFIER_isnt_accurate
[(sizeof(struct lang_identifier) == C_SIZEOF_STRUCT_LANG_IDENTIFIER) ? 1 : -1];
/* The resulting tree type. */
union lang_tree_node
GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
chain_next ("TREE_CODE (&%h.generic) == INTEGER_TYPE ? (union lang_tree_node *)TYPE_NEXT_VARIANT (&%h.generic) : (union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
{
union tree_node GTY ((tag ("0"),
desc ("tree_node_structure (&%h)")))
generic;
struct lang_identifier GTY ((tag ("1"))) identifier;
};
/* Each c_scope structure describes the complete contents of one
scope. Four scopes are distinguished specially: the innermost or
current scope, the innermost function scope, the file scope (always
@ -229,7 +257,7 @@ struct c_binding GTY(())
pop_scope relies on this. */
struct c_scope GTY(())
struct c_scope GTY((chain_next ("%h.outer")))
{
/* The scope containing this one. */
struct c_scope *outer;
@ -4811,6 +4839,13 @@ get_parm_info (bool ellipsis)
and TYPE_DECLs appear here when we have an embedded struct
or union. No warnings for this - we already warned about the
type itself. */
TREE_CHAIN (decl) = others;
others = decl;
/* fall through */
case ERROR_MARK:
/* error_mark_node appears here when we have an undeclared
variable. Just throw it away. */
if (b->id)
{
#ifdef ENABLE_CHECKING
@ -4818,16 +4853,12 @@ get_parm_info (bool ellipsis)
#endif
I_SYMBOL_BINDING (b->id) = b->shadowed;
}
TREE_CHAIN (decl) = others;
others = decl;
break;
/* Other things that might be encountered. */
case LABEL_DECL:
case FUNCTION_DECL:
case VAR_DECL:
case ERROR_MARK:
default:
abort ();
}

View File

@ -41,6 +41,8 @@ enum c_language_kind c_language = clk_c;
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU C"
#undef LANG_HOOKS_IDENTIFIER_SIZE
#define LANG_HOOKS_IDENTIFIER_SIZE C_SIZEOF_STRUCT_LANG_IDENTIFIER
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT c_objc_common_init
#undef LANG_HOOKS_FINISH

View File

@ -24,34 +24,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "c-common.h"
/* Each C symbol points to three linked lists of c_binding structures.
These describe the values of the identifier in the three different
namespaces defined by the language. The contents of these lists
are private to c-decl.c. */
struct c_binding;
/* Language-dependent contents of an identifier. */
struct lang_identifier GTY(())
{
struct c_common_identifier common_id;
struct c_binding *symbol_binding; /* vars, funcs, constants, typedefs */
struct c_binding *tag_binding; /* struct/union/enum tags */
struct c_binding *label_binding; /* labels */
};
/* The resulting tree type. */
union lang_tree_node
GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
chain_next ("TREE_CODE (&%h.generic) == INTEGER_TYPE ? (union lang_tree_node *)TYPE_NEXT_VARIANT (&%h.generic) : (union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
{
union tree_node GTY ((tag ("0"),
desc ("tree_node_structure (&%h)")))
generic;
struct lang_identifier GTY ((tag ("1"))) identifier;
};
/* struct lang_identifier is private to c-decl.c, but langhooks.c needs to
know how big it is. This is sanity-checked in c-decl.c. */
#define C_SIZEOF_STRUCT_LANG_IDENTIFIER \
(sizeof (struct c_common_identifier) + 3 * sizeof (void *))
/* Language-specific declaration information. */

View File

@ -35,6 +35,8 @@ enum c_language_kind c_language = clk_objc;
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU Objective-C"
#undef LANG_HOOKS_IDENTIFIER_SIZE
#define LANG_HOOKS_IDENTIFIER_SIZE C_SIZEOF_STRUCT_LANG_IDENTIFIER
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT objc_init
#undef LANG_HOOKS_FINISH

View File

@ -1,3 +1,7 @@
2004-03-28 Zack Weinberg <zack@codesourcery.com>
* gcc.dg/noncompile/undeclared-2.c: New test.
2004-03-28 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/940409-1.c: Remove XFAIL.

View File

@ -0,0 +1,3 @@
/* Invalid, but should not ICE. PRs 11944, 14734. */
void foo(const int[i]); /* { dg-error "undeclared|for each" } */