summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-decl.c11
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/20020130-1.c9
4 files changed, 26 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 65b1c29868b..841002068fb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-01-31 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * c-decl.c (grokdeclarator): Handle type being a typedef for an
+ invalid type.
+
2002-01-30 David O'Brien <obrien@FreeBSD.org>
* config.gcc: Include sparc/biarch64.h rather than sparc/sparc_bi.h.
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index ad2380931aa..9deb193dae0 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4241,9 +4241,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, width)
/* Actual typedefs come to us as TYPE_DECL nodes. */
else if (TREE_CODE (id) == TYPE_DECL)
{
- type = TREE_TYPE (id);
- decl_attr = DECL_ATTRIBUTES (id);
- typedef_decl = id;
+ if (TREE_TYPE (id) == error_mark_node)
+ ; /* Allow the type to default to int to avoid cascading errors. */
+ else
+ {
+ type = TREE_TYPE (id);
+ decl_attr = DECL_ATTRIBUTES (id);
+ typedef_decl = id;
+ }
}
/* Built-in types come as identifiers. */
else if (TREE_CODE (id) == IDENTIFIER_NODE)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3d1e128ba18..27934b67f9b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-01-31 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * gcc.dg/noncompile/20020130-1.c: New test.
+
2002-01-30 David Billinghurst <David.Billinghurst@riotinto.com>
* g77.dg/f77-edit-i-out.f: Escape \. Allow \r\n and \r.
diff --git a/gcc/testsuite/gcc.dg/noncompile/20020130-1.c b/gcc/testsuite/gcc.dg/noncompile/20020130-1.c
new file mode 100644
index 00000000000..d820e062e71
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noncompile/20020130-1.c
@@ -0,0 +1,9 @@
+/* Test for ICE when using typedef for bad type. */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk>. */
+
+void
+foo (void)
+{
+ typedef int t[x]; /* { dg-error "undeclared|function" "x undeclared" } */
+ t bar;
+}