+2003-12-22 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR c/9163
+ * c-decl.c (poplevel): Only set DECL_INITIAL of a current function
+ if it is non-null.
+ (finish_function): Check for error_mark_node or null on DECL_RESULT and
+ DECL_RESULT of fndecl.
+ (c_expand_body): Only expand when DECL_INITIAL of fndecl is not
+ error_mark_node and not null.
+
2003-12-21 Dan Nicolaescu <dann@ics.uci.edu>
* rtl.h (dump_rtx_statistics): Declare it.
IDENTIFIER_TAG_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p);
/* Dispose of the block that we just made inside some higher level. */
- if (scope->function_body)
+ if (scope->function_body && current_function_decl)
DECL_INITIAL (current_function_decl) = block;
else if (scope->outer)
{
}
}
- BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
+ if (DECL_INITIAL (fndecl) != error_mark_node && DECL_INITIAL (fndecl))
+ BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
/* Must mark the RESULT_DECL as being in this function. */
- DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
+ if (DECL_RESULT (fndecl) != error_mark_node && DECL_RESULT (fndecl))
+ DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted)
{
/* Squirrel away our current state. */
push_function_context ();
}
-
+
tree_rest_of_compilation (fndecl, nested_p);
if (nested_p)
void
c_expand_body (tree fndecl)
{
- c_expand_body_1 (fndecl, 0);
+
+ if (DECL_INITIAL (fndecl) != error_mark_node && DECL_INITIAL (fndecl))
+ c_expand_body_1 (fndecl, 0);
}
\f
/* Check the declarations given in a for-loop for satisfying the C99
--- /dev/null
+/* PR c/9163 */
+/* The following test used to ICE after an error message in C99 mode
+ because GCC was trying to expand the tree to rtl. */
+
+/* { dg-do compile } */
+/* { dg-options "-std=c99" } */
+
+
+
+void f ()
+{
+ for (; int ; ); /* { dg-error "" } */
+}
+
+void foo ()
+{
+ while (int i); /* { dg-error "" } */
+}