FreeBSD/contrib/gcc/c-parser.c
/* Parse the restricted form of the for statment allowed by OpenMP.
   The real trick here is to determine the loop control variable early
   so that we can push a new decl if necessary to make it private.  */
Parse the restricted form of the for statment allowed by OpenMP.
The real trick here is to determine the loop control variable early
so that we can push a new decl if necessary to make it private.
Parse the restricted form of the for statment allowed by OpenMP . The real trick here is to determine the loop control variable early so that we can push a new decl if necessary to make it private .
static tree
c_parser_omp_for_loop (c_parser *parser)
{
  tree decl, cond, incr, save_break, save_cont, body, init;
  location_t loc;
  if (!c_parser_next_token_is_keyword (parser, RID_FOR))
    {
      c_parser_error (parser, "for statement expected");
      return NULL;
    }
  loc = c_parser_peek_token (parser)->location;
  c_parser_consume_token (parser);
  if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
    return NULL;
  if (c_parser_next_token_starts_declspecs (parser))
    {
      c_parser_declaration_or_fndef (parser, true, true, true, true, NULL);
      decl = check_for_loop_decls ();
      if (decl == NULL)
	goto error_init;
      init = decl;
    }
  else if (c_parser_next_token_is (parser, CPP_NAME)
	   && c_parser_peek_2nd_token (parser)->type == CPP_EQ)
    {
      decl = c_parser_postfix_expression (parser).value;
      c_parser_require (parser, CPP_EQ, "expected %<=%>");
      init = c_parser_expr_no_commas (parser, NULL).value;
      init = build_modify_expr (decl, NOP_EXPR, init);
      init = c_process_expr_stmt (init);
      c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
    }
  else
    goto error_init;
  cond = NULL_TREE;
  if (c_parser_next_token_is_not (parser, CPP_SEMICOLON))
    {
      cond = c_parser_expression_conv (parser).value;
      cond = c_objc_common_truthvalue_conversion (cond);
      if (EXPR_P (cond))
	SET_EXPR_LOCATION (cond, input_location);
    }
  c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
  incr = NULL_TREE;
  if (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN))
    incr = c_process_expr_stmt (c_parser_expression (parser).value);
  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
 parse_body:
  save_break = c_break_label;
  c_break_label = size_one_node;
  save_cont = c_cont_label;
  c_cont_label = NULL_TREE;
  body = push_stmt_list ();
  add_stmt (c_parser_c99_block_statement (parser));
  if (c_cont_label)
    add_stmt (build1 (LABEL_EXPR, void_type_node, c_cont_label));
  body = pop_stmt_list (body);
  c_break_label = save_break;
  c_cont_label = save_cont;
  if (decl != NULL && decl != error_mark_node && init != error_mark_node)
    return c_finish_omp_for (loc, decl, init, cond, incr, body, NULL);
  return NULL;
 error_init:
  c_parser_error (parser, "expected iteration declaration or initialization");
  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
  decl = init = cond = incr = NULL_TREE;
  goto parse_body;
}
static tree c_parser_omp_for_loop ( c_parser * parser ) { tree decl , cond , incr , save_break , save_cont , body , init ; location_t loc ; if ( ! c_parser_next_token_is_keyword ( parser , RID_FOR ) ) { c_parser_error ( parser , " " ) ; return NULL ; } loc = c_parser_peek_token ( parser ) -> location ; c_parser_consume_token ( parser ) ; if ( ! c_parser_require ( parser , CPP_OPEN_PAREN , " " ) ) return NULL ; if ( c_parser_next_token_starts_declspecs ( parser ) ) { c_parser_declaration_or_fndef ( parser , true , true , true , true , NULL ) ; decl = check_for_loop_decls ( ) ; if ( decl == NULL ) goto error_init ; init = decl ; } else if ( c_parser_next_token_is ( parser , CPP_NAME ) && c_parser_peek_2nd_token ( parser ) -> type == CPP_EQ ) { decl = c_parser_postfix_expression ( parser ) . value ; c_parser_require ( parser , CPP_EQ , " " ) ; init = c_parser_expr_no_commas ( parser , NULL ) . value ; init = build_modify_expr ( decl , NOP_EXPR , init ) ; init = c_process_expr_stmt ( init ) ; c_parser_skip_until_found ( parser , CPP_SEMICOLON , " " ) ; } else goto error_init ; cond = NULL_TREE ; if ( c_parser_next_token_is_not ( parser , CPP_SEMICOLON ) ) { cond = c_parser_expression_conv ( parser ) . value ; cond = c_objc_common_truthvalue_conversion ( cond ) ; if ( EXPR_P ( cond ) ) SET_EXPR_LOCATION ( cond , input_location ) ; } c_parser_skip_until_found ( parser , CPP_SEMICOLON , " " ) ; incr = NULL_TREE ; if ( c_parser_next_token_is_not ( parser , CPP_CLOSE_PAREN ) ) incr = c_process_expr_stmt ( c_parser_expression ( parser ) . value ) ; c_parser_skip_until_found ( parser , CPP_CLOSE_PAREN , " " ) ; parse_body : save_break = c_break_label ; c_break_label = size_one_node ; save_cont = c_cont_label ; c_cont_label = NULL_TREE ; body = push_stmt_list ( ) ; add_stmt ( c_parser_c99_block_statement ( parser ) ) ; if ( c_cont_label ) add_stmt ( build1 ( LABEL_EXPR , void_type_node , c_cont_label ) ) ; body = pop_stmt_list ( body ) ; c_break_label = save_break ; c_cont_label = save_cont ; if ( decl != NULL && decl != error_mark_node && init != error_mark_node ) return c_finish_omp_for ( loc , decl , init , cond , incr , body , NULL ) ; return NULL ; error_init : c_parser_error ( parser , " " ) ; c_parser_skip_until_found ( parser , CPP_CLOSE_PAREN , " " ) ; decl = init = cond = incr = NULL_TREE ; goto parse_body ; }
Parse the restricted form of the for statment allowed by OpenMP.
Parse the restricted form of the for statment allowed by OpenMP .
/* Parse the initialization declaration or expression.  */ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */ /* Parse the loop condition.  */ /* Parse the increment expression.  */ /* Only bother calling c_finish_omp_for if we havn't already generated
     an error from the initialization parsing.  */