From ad97f4bed6ac21187cce4f9267279d13ae56ecab Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sat, 18 Sep 2004 19:28:14 +0100 Subject: [PATCH] re PR c/17424 (ICE with sizeof an undeclared variable) PR c/17424 * c-typeck.c (c_expr_sizeof_expr): Check for error_mark_node. testsuite: * gcc.dg/pr17424-1.c: New test. From-SVN: r87705 --- gcc/ChangeLog | 5 +++++ gcc/c-typeck.c | 15 ++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr17424-1.c | 5 +++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr17424-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8ac66921107..e733d00f434 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-09-18 Joseph S. Myers + + PR c/17424 + * c-typeck.c (c_expr_sizeof_expr): Check for error_mark_node. + 2004-09-18 Diego Novillo * tree-ssa-alias.c (setup_pointers_and_addressables): Don't diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c00b9ec4a61..a7f776390dd 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1855,9 +1855,18 @@ struct c_expr c_expr_sizeof_expr (struct c_expr expr) { struct c_expr ret; - ret.value = c_sizeof (TREE_TYPE (expr.value)); - ret.original_code = ERROR_MARK; - pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (expr.value))); + if (expr.value == error_mark_node) + { + ret.value = error_mark_node; + ret.original_code = ERROR_MARK; + pop_maybe_used (false); + } + else + { + ret.value = c_sizeof (TREE_TYPE (expr.value)); + ret.original_code = ERROR_MARK; + pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (expr.value))); + } return ret; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4bb46044e19..df5cc5314b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-18 Joseph S. Myers + + PR c/17424 + * gcc.dg/pr17424-1.c: New test. + 2004-09-18 Diego Novillo * g++.dg/tree-ssa/pr17153.C: New test. diff --git a/gcc/testsuite/gcc.dg/pr17424-1.c b/gcc/testsuite/gcc.dg/pr17424-1.c new file mode 100644 index 00000000000..893b4af13d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr17424-1.c @@ -0,0 +1,5 @@ +/* Test for bug 17424: ICE for sizeof an undeclared variable. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +;int foezis = sizeof tni; /* { dg-error "'tni' undeclared" } */ -- 2.30.2