else
fnbody = c_parser_compound_statement (parser, &endloc);
tree fndecl = current_function_decl;
- if (nested)
+ if (nested && specs->declspec_il == cdil_none)
{
tree decl = current_function_decl;
/* Mark nested functions as needing static-chain initially.
c_pop_function_context ();
add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
}
+ else if (nested)
+ {
+ if (specs->declspec_il == cdil_rtl)
+ error ("%<__RTL%> function cannot be a nested function");
+ else
+ error ("%<__GIMPLE%> function cannot be a nested function");
+ finish_function (endloc);
+ c_pop_function_context ();
+ }
else
{
if (fnbody)
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+/* PR c/121421 */
+/* Gimple functions cannot be nested functions. */
+
+
+void main(void)
+{
+ void __GIMPLE b(){} /* { dg-error "cannot be a nested" } */
+}