re PR c/17424 (ICE with sizeof an undeclared variable)
authorJoseph Myers <jsm@polyomino.org.uk>
Sat, 18 Sep 2004 18:28:14 +0000 (19:28 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sat, 18 Sep 2004 18:28:14 +0000 (19:28 +0100)
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
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr17424-1.c [new file with mode: 0644]

index 8ac669211072193cd55a943a9958728c2ab80468..e733d00f43457ea8e07c24a86fd5d8f6a522bd81 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-18  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       PR c/17424
+       * c-typeck.c (c_expr_sizeof_expr): Check for error_mark_node.
+
 2004-09-18  Diego Novillo  <dnovillo@redhat.com>
 
        * tree-ssa-alias.c (setup_pointers_and_addressables): Don't
index c00b9ec4a616b848395000beb9d594d52e427af7..a7f776390ddc0e7ae97c40d47844db3edce1ef3d 100644 (file)
@@ -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;
 }
 
index 4bb46044e19981d92b4bc4eea37bfbd132c537b9..df5cc5314b351c9b640690f6d34c699d65f8f3ba 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-18  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       PR c/17424
+       * gcc.dg/pr17424-1.c: New test.
+
 2004-09-18  Diego Novillo  <dnovillo@redhat.com>
 
        * 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 (file)
index 0000000..893b4af
--- /dev/null
@@ -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" } */