Declarator DeclaratorInfo(DS, (Declarator::TheContext)Context);
ParseDeclarator(DeclaratorInfo);
- return ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
+ DeclGroupPtrTy DG =
+ ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
+
+ if (Tok.is(tok::semi)) {
+ ConsumeToken();
+ // for(is key; in keys) is error.
+ if (Context == Declarator::ForContext && isTokIdentifier_in())
+ Diag(Tok, diag::err_parse_error);
+
+ return DG;
+ }
+
+ // If this is an ObjC2 for-each loop, this is a successful declarator
+ // parse. The syntax for these looks like:
+ // 'for' '(' declaration 'in' expr ')' statement
+ if (Context == Declarator::ForContext && isTokIdentifier_in())
+ return DG;
+
+ Diag(Tok, diag::err_expected_semi_declation);
+ // Skip to end of block or statement
+ SkipUntil(tok::r_brace, true, true);
+ if (Tok.is(tok::semi))
+ ConsumeToken();
+ return DG;
}
SourceLocation Loc;
OwningExprResult AsmLabel(ParseSimpleAsm(&Loc));
if (AsmLabel.isInvalid()) {
- SkipUntil(tok::semi);
+ SkipUntil(tok::semi, true, true);
return DeclGroupPtrTy();
}
} else {
OwningExprResult Init(ParseInitializer());
if (Init.isInvalid()) {
- SkipUntil(tok::semi);
+ SkipUntil(tok::semi, true, true);
return DeclGroupPtrTy();
}
Actions.AddInitializerToDecl(ThisDecl, move(Init));
ParseDeclarator(D);
}
- if (Tok.is(tok::semi)) {
- ConsumeToken();
- // for(is key; in keys) is error.
- if (D.getContext() == Declarator::ForContext && isTokIdentifier_in()) {
- Diag(Tok, diag::err_parse_error);
- return DeclGroupPtrTy();
- }
-
- return Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
- DeclsInGroup.size());
- }
-
- // If this is an ObjC2 for-each loop, this is a successful declarator
- // parse. The syntax for these looks like:
- // 'for' '(' declaration 'in' expr ')' statement
- if (D.getContext() == Declarator::ForContext && isTokIdentifier_in())
- return Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
- DeclsInGroup.size());
-
- Diag(Tok, diag::err_parse_error);
- // Skip to end of block or statement
- SkipUntil(tok::r_brace, true, true);
- if (Tok.is(tok::semi))
- ConsumeToken();
- return DeclGroupPtrTy();
+ return Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+ DeclsInGroup.size());
}
/// ParseSpecifierQualifierList
Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def
Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def
(getLang().CPlusPlus &&
- Tok.is(tok::l_paren)) ) { // int X(0) -> not a function def [C++]
+ Tok.is(tok::l_paren))) { // int X(0) -> not a function def [C++]
// Parse the init-declarator-list for a normal declaration.
- return ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
+ DeclGroupPtrTy DG =
+ ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
+ // Eat the semi colon after the declaration.
+ ExpectAndConsume(tok::semi, diag::err_expected_semi_declation);
+ return DG;
}
/// [C90] function-definition: [C99 6.7.1] - implicit int result
/// [C90] decl-specs[opt] declarator declaration-list[opt] compound-statement
/// [C++] function-definition: [C++ 8.4]
-/// decl-specifier-seq[opt] declarator ctor-initializer[opt] function-body
+/// decl-specifier-seq[opt] declarator ctor-initializer[opt]
+/// function-body
/// [C++] function-definition: [C++ 8.4]
/// decl-specifier-seq[opt] declarator function-try-block [TODO]
///
short typeof (int) aShortInt; // expected-error{{'short typeof' is invalid}}
int int ttt; // expected-error{{cannot combine with previous 'int' declaration specifier}}
typeof(TInt) anInt;
- short TInt eee; // expected-error{{parse error}}
- void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{parse error}}
+ short TInt eee; // expected-error{{expected ';' at end of declaration}}
+ void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{expected ';' at end of declaration}}
typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-note {{to match this '('}} expected-warning {{type specifier missing, defaults to 'int'}}
typeof(const int) aci;
const typeof (*pi) aConstInt;