--token_anchor_set[token_kind];
}
-/**
- * Return true if the token type of the current token is
- * in the anchor set.
- */
-static bool at_anchor(void)
-{
- if (token.kind < 0)
- return false;
- return token_anchor_set[token.kind];
-}
-
/**
* Eat tokens until a matching token type is found.
*/
anchor = &argument->next;
} while (next_if(','));
expect(')', end_error);
-
- return first;
-
end_error:
- /* TODO... */
return first;
}
eat(T__declspec);
expect('(', end_error);
+ if (token.kind != ')') {
+ add_anchor_token(')');
- if (next_if(')'))
- return NULL;
-
- add_anchor_token(')');
-
- attribute_t **anchor = &first;
- do {
- while (*anchor != NULL)
- anchor = &(*anchor)->next;
+ attribute_t **anchor = &first;
+ do {
+ while (*anchor != NULL)
+ anchor = &(*anchor)->next;
- attribute_t *attribute
- = parse_microsoft_extended_decl_modifier_single();
- if (attribute == NULL)
- goto end_error;
+ attribute_t *attribute
+ = parse_microsoft_extended_decl_modifier_single();
+ if (attribute == NULL)
+ break;
- *anchor = attribute;
- anchor = &attribute->next;
- } while (next_if(','));
+ *anchor = attribute;
+ anchor = &attribute->next;
+ } while (next_if(','));
- rem_anchor_token(')');
+ rem_anchor_token(')');
+ }
expect(')', end_error);
- return first;
-
end_error:
- rem_anchor_token(')');
return first;
}
expect(')', end_error);
expect(';', end_error);
+end_error:
if (asm_statement->outputs == NULL) {
/* GCC: An 'asm' instruction without any output operands will be treated
* identically to a volatile 'asm' instruction. */
}
return statement;
-end_error:
- return create_error_statement();
}
static statement_t *parse_label_inner_statement(statement_t const *const label, char const *const label_kind)
statement->do_while.body = parse_loop_body(statement);
rem_anchor_token(T_while);
- expect(T_while, end_error);
+ expect(T_while, end_error0);
+end_error0:;
expression_t *const cond = parse_condition();
statement->do_while.condition = cond;
/* ยง6.8.5:2 The controlling expression of an iteration statement shall
* have scalar type. */
semantic_condition(cond, "condition of 'do-while'-statement");
- expect(';', end_error);
+ expect(';', end_error1);
+end_error1:
POP_PARENT();
return statement;
-end_error:
- POP_PARENT();
- return create_error_statement();
}
/**
eat(T_for);
- expect('(', end_error1);
- add_anchor_token(')');
-
PUSH_PARENT(statement);
PUSH_SCOPE(&statement->fors.scope);
+ expect('(', end_error1);
+ add_anchor_token(')');
+
PUSH_EXTENSION();
if (next_if(';')) {
warningf(WARN_UNUSED_VALUE, &init->base.source_position, "initialisation of 'for'-statement has no effect");
}
rem_anchor_token(';');
- expect(';', end_error2);
+ expect(';', end_error3);
+end_error3:;
}
POP_EXTENSION();
rem_anchor_token(';');
}
expect(';', end_error2);
+end_error2:
if (token.kind != ')') {
expression_t *const step = parse_expression();
statement->fors.step = step;
warningf(WARN_UNUSED_VALUE, &step->base.source_position, "step of 'for'-statement has no effect");
}
}
- expect(')', end_error2);
rem_anchor_token(')');
+ expect(')', end_error1);
+end_error1:
statement->fors.body = parse_loop_body(statement);
POP_SCOPE();
POP_PARENT();
return statement;
-
-end_error2:
- POP_PARENT();
- rem_anchor_token(')');
- POP_SCOPE();
- /* fallthrough */
-
-end_error1:
- return create_error_statement();
}
/**
else
parse_error_expected("while parsing goto", T_IDENTIFIER, NULL);
eat_until_anchor();
- return create_error_statement();
+ statement->gotos.label = &allocate_entity_zero(ENTITY_LABEL, NAMESPACE_LABEL, sym_anonymous)->label;
}
}
statement_t **anchor = &statement->compound.statements;
bool only_decls_so_far = true;
- while (token.kind != '}') {
- if (token.kind == T_EOF) {
- errorf(&statement->base.source_position,
- "EOF while parsing compound statement");
- break;
- }
+ while (token.kind != '}' && token.kind != T_EOF) {
statement_t *sub_statement = intern_parse_statement();
if (sub_statement->kind == STATEMENT_ERROR) {
- /* an error occurred. if we are at an anchor, return */
- if (at_anchor())
- goto end_error;
- continue;
+ break;
}
if (sub_statement->kind != STATEMENT_DECLARATION) {
}
*anchor = sub_statement;
-
- while (sub_statement->base.next != NULL)
- sub_statement = sub_statement->base.next;
-
- anchor = &sub_statement->base.next;
+ anchor = &sub_statement->base.next;
}
- next_token();
+ expect('}', end_error);
+end_error:
/* look over all statements again to produce no effect warnings */
if (is_warn_on(WARN_UNUSED_VALUE)) {
}
}
-end_error:
rem_anchor_token(T_while);
rem_anchor_token(T_wchar_t);
rem_anchor_token(T_volatile);