OSDN Git Service

* c-decl.c (grokdeclarator): Handle type being a typedef for an
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Jan 2002 01:01:02 +0000 (01:01 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Jan 2002 01:01:02 +0000 (01:01 +0000)
invalid type.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49352 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 65b1c29..8410020 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 ad23809..9deb193 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 3d1e128..27934b6 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;
+}