aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2004-03-28 17:45:57 +0000
committerZack Weinberg <zack@gcc.gnu.org>2004-03-28 17:45:57 +0000
commit18d5f9820c77f9d84ec379117bef8ed18bcc3ba8 (patch)
treee95abdb07c80f3f34dfb27ad9081ce47469bc52a /gcc
parentf26e5597f0272d7e4e20fe2c3728a064276f6ab0 (diff)
downloadgcc-18d5f9820c77f9d84ec379117bef8ed18bcc3ba8.zip
gcc-18d5f9820c77f9d84ec379117bef8ed18bcc3ba8.tar.gz
gcc-18d5f9820c77f9d84ec379117bef8ed18bcc3ba8.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog34
-rw-r--r--gcc/c-decl.c43
-rw-r--r--gcc/c-lang.c2
-rw-r--r--gcc/c-tree.h32
-rw-r--r--gcc/objc/objc-lang.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/undeclared-2.c3
7 files changed, 77 insertions, 43 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bb64ccc..ea79883 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,8 +1,24 @@
+2004-03-28 Zack Weinberg <zack@codesourcery.com>
+
+ * 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>
+ Dorit Naishlos <dorit@il.ibm.com>
- * config/rs6000/altivec.md: (andvv16qi3, andv8hi3, one_cmplv16qi2,
- one_cmplv8hi2, one_cmplv4si2, iorv16qi3, iorv8hi3,): New modelling.
+ * 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>
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index b2a0bf5..05bc8be 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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 ();
}
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index 391e8bd..93dc405 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -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
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index eb167ca..01f86e9 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -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. */
diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c
index 877867a..2853ded 100644
--- a/gcc/objc/objc-lang.c
+++ b/gcc/objc/objc-lang.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0b19b8c..96a9625 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/noncompile/undeclared-2.c b/gcc/testsuite/gcc.dg/noncompile/undeclared-2.c
new file mode 100644
index 0000000..36cd0ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noncompile/undeclared-2.c
@@ -0,0 +1,3 @@
+/* Invalid, but should not ICE. PRs 11944, 14734. */
+
+void foo(const int[i]); /* { dg-error "undeclared|for each" } */