FreeBSD/contrib/gcc/cp/parser.c
/* Parse a statement.

   statement:
     labeled-statement
     expression-statement
     compound-statement
     selection-statement
     iteration-statement
     jump-statement
     declaration-statement
     try-block

  IN_COMPOUND is true when the statement is nested inside a
  cp_parser_compound_statement; this matters for certain pragmas.

  If IF_P is not NULL, *IF_P is set to indicate whether the statement
  is a (possibly labeled) if statement which is not enclosed in braces
  and has an else clause.  This is used to implement -Wparentheses.  */
Parse a statement.

IN_COMPOUND is true when the statement is nested inside a
cp_parser_compound_statement; this matters for certain pragmas.

If IF_P is not NULL, *IF_P is set to indicate whether the statement
is a (possibly labeled) if statement which is not enclosed in braces
and has an else clause.  This is used to implement -Wparentheses.
Parse a statement . IN_COMPOUND is true when the statement is nested inside a cp_parser_compound_statement ; this matters for certain pragmas . If IF_P is not NULL * IF_P is set to indicate whether the statement is a ( possibly labeled ) if statement which is not enclosed in braces and has an else clause . This is used to implement - Wparentheses .
static void
cp_parser_statement (cp_parser* parser, tree in_statement_expr,
		     bool in_compound, bool *if_p)
{
  tree statement;
  cp_token *token;
  location_t statement_location;
 restart:
  if (if_p != NULL)
    *if_p = false;
  statement = NULL_TREE;
  token = cp_lexer_peek_token (parser->lexer);
  statement_location = token->location;
  if (token->type == CPP_KEYWORD)
    {
      enum rid keyword = token->keyword;
      switch (keyword)
	{
	case RID_CASE:
	case RID_DEFAULT:
	  cp_parser_label_for_labeled_statement (parser);
	  goto restart;
	case RID_IF:
	case RID_SWITCH:
	  statement = cp_parser_selection_statement (parser, if_p);
	  break;
	case RID_WHILE:
	case RID_DO:
	case RID_FOR:
	  statement = cp_parser_iteration_statement (parser);
	  break;
	case RID_BREAK:
	case RID_CONTINUE:
	case RID_RETURN:
	case RID_GOTO:
	  statement = cp_parser_jump_statement (parser);
	  break;
	case RID_AT_TRY:
	case RID_AT_CATCH:
	case RID_AT_FINALLY:
	case RID_AT_SYNCHRONIZED:
	case RID_AT_THROW:
	  statement = cp_parser_objc_statement (parser);
	  break;
	case RID_TRY:
	  statement = cp_parser_try_block (parser);
	  break;
	default:
	  break;
	}
    }
  else if (token->type == CPP_NAME)
    {
      token = cp_lexer_peek_nth_token (parser->lexer, 2);
      if (token->type == CPP_COLON)
	{
	  cp_parser_label_for_labeled_statement (parser);
	  goto restart;
	}
    }
  else if (token->type == CPP_OPEN_BRACE)
    statement = cp_parser_compound_statement (parser, NULL, false, false);
  else if (token->type == CPP_PRAGMA)
    {
      if (in_compound)
	cp_parser_pragma (parser, pragma_compound);
      else if (!cp_parser_pragma (parser, pragma_stmt))
	goto restart;
      return;
    }
  else if (token->type == CPP_EOF)
    {
      cp_parser_error (parser, "expected statement");
      return;
    }
  if (!statement)
    {
      if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
	{
	  cp_parser_parse_tentatively (parser);
	  cp_parser_declaration_statement (parser);
	  if (cp_parser_parse_definitely (parser))
	    return;
	}
      statement = cp_parser_expression_statement (parser, in_statement_expr);
    }
  if (statement && STATEMENT_CODE_P (TREE_CODE (statement)))
    SET_EXPR_LOCATION (statement, statement_location);
}
static void cp_parser_statement ( cp_parser * parser , tree in_statement_expr , bool in_compound , bool * if_p ) { tree statement ; cp_token * token ; location_t statement_location ; restart : if ( if_p != NULL ) * if_p = false ; statement = NULL_TREE ; token = cp_lexer_peek_token ( parser -> lexer ) ; statement_location = token -> location ; if ( token -> type == CPP_KEYWORD ) { enum rid keyword = token -> keyword ; switch ( keyword ) { case RID_CASE : case RID_DEFAULT : cp_parser_label_for_labeled_statement ( parser ) ; goto restart ; case RID_IF : case RID_SWITCH : statement = cp_parser_selection_statement ( parser , if_p ) ; break ; case RID_WHILE : case RID_DO : case RID_FOR : statement = cp_parser_iteration_statement ( parser ) ; break ; case RID_BREAK : case RID_CONTINUE : case RID_RETURN : case RID_GOTO : statement = cp_parser_jump_statement ( parser ) ; break ; case RID_AT_TRY : case RID_AT_CATCH : case RID_AT_FINALLY : case RID_AT_SYNCHRONIZED : case RID_AT_THROW : statement = cp_parser_objc_statement ( parser ) ; break ; case RID_TRY : statement = cp_parser_try_block ( parser ) ; break ; default : break ; } } else if ( token -> type == CPP_NAME ) { token = cp_lexer_peek_nth_token ( parser -> lexer , 2 ) ; if ( token -> type == CPP_COLON ) { cp_parser_label_for_labeled_statement ( parser ) ; goto restart ; } } else if ( token -> type == CPP_OPEN_BRACE ) statement = cp_parser_compound_statement ( parser , NULL , false , false ) ; else if ( token -> type == CPP_PRAGMA ) { if ( in_compound ) cp_parser_pragma ( parser , pragma_compound ) ; else if ( ! cp_parser_pragma ( parser , pragma_stmt ) ) goto restart ; return ; } else if ( token -> type == CPP_EOF ) { cp_parser_error ( parser , " " ) ; return ; } if ( ! statement ) { if ( cp_lexer_next_token_is_not ( parser -> lexer , CPP_SEMICOLON ) ) { cp_parser_parse_tentatively ( parser ) ; cp_parser_declaration_statement ( parser ) ; if ( cp_parser_parse_definitely ( parser ) ) return ; } statement = cp_parser_expression_statement ( parser , in_statement_expr ) ; } if ( statement && STATEMENT_CODE_P ( TREE_CODE ( statement ) ) ) SET_EXPR_LOCATION ( statement , statement_location ) ; }
Parse a statement.
Parse a statement .
/* There is no statement yet.  */ /* Peek at the next token.  */ /* Remember the location of the first token in the statement.  */ /* If this is a keyword, then that will often determine what kind of
     statement we have.  */ /* Looks like a labeled-statement with a case label.
	     Parse the label, and then use tail recursion to parse
	     the statement.  */ /* Objective-C++ exception-handling constructs.  */ /* It might be a keyword like `int' that can start a
	     declaration-statement.  */ /* If the next token is a `:', then we are looking at a
	 labeled-statement.  */ /* Looks like a labeled-statement with an ordinary label.
	     Parse the label, and then use tail recursion to parse
	     the statement.  */ /* Anything that starts with a `{' must be a compound-statement.  */ /* APPLE LOCAL radar 5982990 */ /* CPP_PRAGMA is a #pragma inside a function body, which constitutes
     a statement all its own.  */ /* Only certain OpenMP pragmas are attached to statements, and thus
	 are considered statements themselves.  All others are not.  In
	 the context of a compound, accept the pragma as a "statement" and
	 return so that we can check for a close brace.  Otherwise we
	 require a real statement and must go back and read one.  */ /* Everything else must be a declaration-statement or an
     expression-statement.  Try for the declaration-statement
     first, unless we are looking at a `;', in which case we know that
     we have an expression-statement.  */ /* Try to parse the declaration-statement.  */ /* If that worked, we're done.  */ /* Look for an expression-statement instead.  */ /* Set the line number for the statement.  */