X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=parser.c;h=18c59f656851deecc331be7841c667baaacc1377;hb=fb42589fd477ec7892f224e71d9be3820d0106c6;hp=ad746a0b0e8a5ac54ebd2a07d388de4af030b0da;hpb=9bf914ca0a1473ee629d30d8a6a65cfbd633712b;p=cparser diff --git a/parser.c b/parser.c index ad746a0..18c59f6 100644 --- a/parser.c +++ b/parser.c @@ -3220,7 +3220,11 @@ static bool has_parameters(void) type_t const *const type = skip_typeref(entity->typedefe.type); if (!is_type_void(type)) return true; - if (type->base.qualifiers != TYPE_QUALIFIER_NONE) { + if (c_mode & _CXX) { + /* ISO/IEC 14882:1998(E) §8.3.5:2 It must be literally (void). A typedef + * is not allowed. */ + errorf(HERE, "empty parameter list defined with a typedef of 'void' not allowed in C++"); + } else if (type->base.qualifiers != TYPE_QUALIFIER_NONE) { /* §6.7.5.3:10 Qualification is not allowed here. */ errorf(HERE, "'void' as parameter must not have type qualifiers"); } @@ -9997,7 +10001,6 @@ static statement_t *intern_parse_statement(void) statement_t *statement = NULL; /* declaration or statement */ - add_anchor_token(';'); switch (token.kind) { case T_IDENTIFIER: { token_kind_t la1_type = (token_kind_t)look_ahead(1)->kind; @@ -10068,11 +10071,9 @@ static statement_t *intern_parse_statement(void) default: errorf(HERE, "unexpected token %K while parsing statement", &token); statement = create_error_statement(); - if (!at_anchor()) - next_token(); + eat_until_anchor(); break; } - rem_anchor_token(';'); assert(statement != NULL && statement->base.source_position.input_name != NULL); @@ -10120,6 +10121,7 @@ static statement_t *parse_compound_statement(bool inside_expression_statement) add_anchor_token('*'); add_anchor_token('+'); add_anchor_token('-'); + add_anchor_token(';'); add_anchor_token('{'); add_anchor_token('~'); add_anchor_token(T_CHARACTER_CONSTANT); @@ -10332,6 +10334,7 @@ end_error: rem_anchor_token(T_CHARACTER_CONSTANT); rem_anchor_token('~'); rem_anchor_token('{'); + rem_anchor_token(';'); rem_anchor_token('-'); rem_anchor_token('+'); rem_anchor_token('*');