FreeBSD/contrib/gcc/c-parser.c
/* Parse a compound statement except for the opening brace.  This is
   used for parsing both compound statements and statement expressions
   (which follow different paths to handling the opening).  */
Parse a compound statement except for the opening brace.  This is
used for parsing both compound statements and statement expressions
(which follow different paths to handling the opening).
Parse a compound statement except for the opening brace . This is used for parsing both compound statements and statement expressions ( which follow different paths to handling the opening ) .
static void
c_parser_compound_statement_nostart (c_parser *parser)
{
  bool last_stmt = false;
  bool last_label = false;
  bool first_stmt = true;
  if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    {
      c_parser_consume_token (parser);
      return;
    }
  if (c_parser_next_token_is_keyword (parser, RID_LABEL))
    {
      while (c_parser_next_token_is_keyword (parser, RID_LABEL))
		{
	c_parser_consume_token (parser);
	while (true)
	{
		tree label;
		if (c_parser_next_token_is_not (parser, CPP_NAME))
		{
			c_parser_error (parser, "expected identifier");
			break;
		}
		label
		= declare_label (c_parser_peek_token (parser)->value);
		C_DECLARED_LABEL_FLAG (label) = 1;
		add_stmt (build_stmt (DECL_EXPR, label));
		c_parser_consume_token (parser);
		if (c_parser_next_token_is (parser, CPP_COMMA))
			c_parser_consume_token (parser);
		else
			break;
	}
	c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
		}
      if (pedantic)
	pedwarn ("ISO C forbids label declarations");
    }
  if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    {
      c_parser_error (parser, "expected declaration or statement");
      c_parser_consume_token (parser);
      return;
    }
  while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE))
    {
      location_t loc = c_parser_peek_token (parser)->location;
      if (c_parser_next_token_is_keyword (parser, RID_CASE)
	|| c_parser_next_token_is_keyword (parser, RID_DEFAULT)
	|| (c_parser_next_token_is (parser, CPP_NAME)
		&& c_parser_peek_2nd_token (parser)->type == CPP_COLON))
      {
	last_label = true;
	last_stmt = false;
	c_parser_label (parser);
      }
      else if (!last_label
		 && c_parser_next_token_starts_declspecs (parser))
      {
	last_label = false;
	c_parser_declaration_or_fndef (parser, true, true, true, true, NULL);
	if (last_stmt
		&& ((pedantic && !flag_isoc99)
			|| warn_declaration_after_statement))
		pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
					 &loc);
	last_stmt = false;
      }
      else if (!last_label
		 && c_parser_next_token_is_keyword (parser, RID_EXTENSION))
      {
	while (c_parser_peek_2nd_token (parser)->type == CPP_KEYWORD
		   && (c_parser_peek_2nd_token (parser)->keyword
			   == RID_EXTENSION))
		c_parser_consume_token (parser);
	if (c_token_starts_declspecs (c_parser_peek_2nd_token (parser)))
	{
		int ext;
		ext = disable_extension_diagnostics ();
		c_parser_consume_token (parser);
		last_label = false;
		c_parser_declaration_or_fndef (parser, true, true, true, true, NULL);
		restore_extension_diagnostics (ext);
		if (last_stmt
			&& ((pedantic && !flag_isoc99)
				|| warn_declaration_after_statement))
			pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
						 &loc);
		last_stmt = false;
	}
	else
		goto statement;
      }
      else if (c_parser_next_token_is (parser, CPP_PRAGMA))
      {
	if (c_parser_pragma (parser, pragma_compound))
		last_label = false, last_stmt = true;
      }
      else if (c_parser_next_token_is (parser, CPP_EOF))
      {
	c_parser_error (parser, "expected declaration or statement");
	return;
      }
      else
      {
      statement:
	last_label = false;
	last_stmt = true;
	c_parser_statement_after_labels (parser);
      }
      parser->error = false;
      first_stmt = false;
    }
  if (last_label)
    error ("label at end of compound statement");
  c_parser_consume_token (parser);
}
static void c_parser_compound_statement_nostart ( c_parser * parser ) { bool last_stmt = false ; bool last_label = false ; bool first_stmt = true ; if ( c_parser_next_token_is ( parser , CPP_CLOSE_BRACE ) ) { c_parser_consume_token ( parser ) ; return ; } if ( c_parser_next_token_is_keyword ( parser , RID_LABEL ) ) { while ( c_parser_next_token_is_keyword ( parser , RID_LABEL ) ) { c_parser_consume_token ( parser ) ; while ( true ) { tree label ; if ( c_parser_next_token_is_not ( parser , CPP_NAME ) ) { c_parser_error ( parser , " " ) ; break ; } label = declare_label ( c_parser_peek_token ( parser ) -> value ) ; C_DECLARED_LABEL_FLAG ( label ) = 1 ; add_stmt ( build_stmt ( DECL_EXPR , label ) ) ; c_parser_consume_token ( parser ) ; if ( c_parser_next_token_is ( parser , CPP_COMMA ) ) c_parser_consume_token ( parser ) ; else break ; } c_parser_skip_until_found ( parser , CPP_SEMICOLON , " " ) ; } if ( pedantic ) pedwarn ( " " ) ; } if ( c_parser_next_token_is ( parser , CPP_CLOSE_BRACE ) ) { c_parser_error ( parser , " " ) ; c_parser_consume_token ( parser ) ; return ; } while ( c_parser_next_token_is_not ( parser , CPP_CLOSE_BRACE ) ) { location_t loc = c_parser_peek_token ( parser ) -> location ; if ( c_parser_next_token_is_keyword ( parser , RID_CASE ) || c_parser_next_token_is_keyword ( parser , RID_DEFAULT ) || ( c_parser_next_token_is ( parser , CPP_NAME ) && c_parser_peek_2nd_token ( parser ) -> type == CPP_COLON ) ) { last_label = true ; last_stmt = false ; c_parser_label ( parser ) ; } else if ( ! last_label && c_parser_next_token_starts_declspecs ( parser ) ) { last_label = false ; c_parser_declaration_or_fndef ( parser , true , true , true , true , NULL ) ; if ( last_stmt && ( ( pedantic && ! flag_isoc99 ) || warn_declaration_after_statement ) ) pedwarn_c90 ( " " , & loc ) ; last_stmt = false ; } else if ( ! last_label && c_parser_next_token_is_keyword ( parser , RID_EXTENSION ) ) { while ( c_parser_peek_2nd_token ( parser ) -> type == CPP_KEYWORD && ( c_parser_peek_2nd_token ( parser ) -> keyword == RID_EXTENSION ) ) c_parser_consume_token ( parser ) ; if ( c_token_starts_declspecs ( c_parser_peek_2nd_token ( parser ) ) ) { int ext ; ext = disable_extension_diagnostics ( ) ; c_parser_consume_token ( parser ) ; last_label = false ; c_parser_declaration_or_fndef ( parser , true , true , true , true , NULL ) ; restore_extension_diagnostics ( ext ) ; if ( last_stmt && ( ( pedantic && ! flag_isoc99 ) || warn_declaration_after_statement ) ) pedwarn_c90 ( " " , & loc ) ; last_stmt = false ; } else goto statement ; } else if ( c_parser_next_token_is ( parser , CPP_PRAGMA ) ) { if ( c_parser_pragma ( parser , pragma_compound ) ) last_label = false , last_stmt = true ; } else if ( c_parser_next_token_is ( parser , CPP_EOF ) ) { c_parser_error ( parser , " " ) ; return ; } else { statement : last_label = false ; last_stmt = true ; c_parser_statement_after_labels ( parser ) ; } parser -> error = false ; first_stmt = false ; } if ( last_label ) error ( " " ) ; c_parser_consume_token ( parser ) ; }
Parse a compound statement except for the opening brace.
Parse a compound statement except for the opening brace .
/* APPLE LOCAL radar 5732232 - blocks (not in C++) */ /* Read zero or more forward-declarations for labels that nested
	 functions can jump to.  */ /* Any identifiers, including those declared as type names,
	 are OK here.  */ /* ??? Locating this diagnostic on the token after the
	 declarations end follows the old parser, but it might be
	 better to locate it where the declarations start instead.  */ /* We must now have at least one statement, label or declaration.  */ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */ /* __extension__ can start a declaration, but is also an
	 unary operator that can start an expression.  Consume all
	 but the last of a possible series of __extension__ to
	 determine which.  */ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */ /* Following the old parser, __extension__ does not
		 disable this diagnostic.  */ /* External pragmas, and some omp pragmas, are not associated
	 with regular c code, and so are not to be considered statements
	 syntactically.  This ensures that the user doesn't put them
	 places that would turn into syntax errors if the directive
	 were ignored.  */ /* APPLE LOCAL radar 5732232 - blocks (not in C++) */