From 16464cc1bba0fd0befabcb90bad7d28b3e229c93 Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Tue, 30 May 2006 13:33:17 +0000 Subject: [PATCH] re PR c/27718 (ICE with sizeof of incomplete type) PR c/27718 * c-typeck.c (c_expr_sizeof_type): Handle invalid types. * gcc.dg/sizeof-1.c: New test. From-SVN: r114234 --- gcc/ChangeLog | 5 +++++ gcc/c-typeck.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/sizeof-1.c | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/sizeof-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 482f4a5d543..c5470be129a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2006-05-30 Volker Reichelt + + PR c/27718 + * c-typeck.c (c_expr_sizeof_type): Handle invalid types. + 2006-05-30 Zdenek Dvorak PR tree-optimization/27779 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 7a8cdc40e23..2c5736cf769 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2153,7 +2153,8 @@ c_expr_sizeof_type (struct c_type_name *t) type = groktypename (t); ret.value = c_sizeof (type); ret.original_code = ERROR_MARK; - pop_maybe_used (C_TYPE_VARIABLE_SIZE (type)); + pop_maybe_used (type != error_mark_node + ? C_TYPE_VARIABLE_SIZE (type) : false); return ret; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eedd466c2ca..dc0ec7cf698 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-05-30 Volker Reichelt + + PR c/27718 + * gcc.dg/sizeof-1.c: New test. + 2006-05-30 Uros Bizjak PR target/27790 diff --git a/gcc/testsuite/gcc.dg/sizeof-1.c b/gcc/testsuite/gcc.dg/sizeof-1.c new file mode 100644 index 00000000000..9541a4c273a --- /dev/null +++ b/gcc/testsuite/gcc.dg/sizeof-1.c @@ -0,0 +1,4 @@ +/* PR c/27718 */ +/* { dg-do compile } */ + +int i = sizeof(struct A[]); /* { dg-error "incomplete" } */