c-decl.c (grokdeclarator): Handle type being a typedef for an invalid type.
authorJoseph Myers <jsm28@cam.ac.uk>
Thu, 31 Jan 2002 01:01:02 +0000 (01:01 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Thu, 31 Jan 2002 01:01:02 +0000 (01:01 +0000)
* c-decl.c (grokdeclarator): Handle type being a typedef for an
invalid type.

testsuite:
* gcc.dg/noncompile/20020130-1.c: New test.

From-SVN: r49352

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/20020130-1.c [new file with mode: 0644]

index 65b1c29868b428eb2e7202225ea0d27f493d024a..841002068fbb334727c0f1fc3e36a7a4509e8594 100644 (file)
@@ -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.
index ad2380931aacfd3a21263b7a4908cf3fe8806ff4..9deb193dae0c35521e26cf77f0c220545f5cd30b 100644 (file)
@@ -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)
index 3d1e128ba18af35194c180a368f292dfaaa10416..27934b67f9b3be1b9b2d6d968b027a4f0d746bdb 100644 (file)
@@ -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 (file)
index 0000000..d820e06
--- /dev/null
@@ -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;
+}