From b36e470aa729054c24a90e54cf766f83bfdb91cf Mon Sep 17 00:00:00 2001 From: jsm28 Date: Thu, 31 Jan 2002 01:01:02 +0000 Subject: [PATCH] * c-decl.c (grokdeclarator): Handle type being a typedef for an 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 | 5 +++++ gcc/c-decl.c | 11 ++++++++--- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/noncompile/20020130-1.c | 9 +++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/noncompile/20020130-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 65b1c29..8410020 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-01-31 Joseph S. Myers + + * c-decl.c (grokdeclarator): Handle type being a typedef for an + invalid type. + 2002-01-30 David O'Brien * 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 ad23809..9deb193 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 3d1e128..27934b6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-01-31 Joseph S. Myers + + * gcc.dg/noncompile/20020130-1.c: New test. + 2002-01-30 David Billinghurst * 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 0000000..d820e06 --- /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 . */ + +void +foo (void) +{ + typedef int t[x]; /* { dg-error "undeclared|function" "x undeclared" } */ + t bar; +} -- 2.7.4