Add parsing support for @unknown (SE-0192)

This is our first statement attribute, made more complicated by the
fact that a 'case'/'default' isn't really a normal statement. I've
chosen /not/ to implement a general statement attribute logic like we
have for types and decls at this time, but I did get the compiler
parsing arbitrary attributes before 'case' and 'default'. As a bonus,
we now treat all cases within functions as being switch-like rather
than enum-like, which is better for recovery when not in a switch.
This commit is contained in:
Jordan Rose
2018-04-05 15:28:19 -07:00
parent f26664b1f1
commit 701975ad1d
16 changed files with 265 additions and 37 deletions

View File

@@ -278,7 +278,7 @@ deriveBodyCodingKey_enum_stringValue(AbstractFunctionDecl *strValDecl) {
SourceLoc());
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem,
/*HasBoundDecls=*/false, SourceLoc(),
caseBody));
SourceLoc(), caseBody));
}
auto *selfRef = createSelfDeclRef(strValDecl);
@@ -346,7 +346,7 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl) {
SourceLoc());
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem,
/*HasBoundDecls=*/false, SourceLoc(),
body));
SourceLoc(), body));
}
auto *anyPat = new (C) AnyPattern(SourceLoc());
@@ -358,7 +358,7 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl) {
SourceLoc());
cases.push_back(CaseStmt::create(C, SourceLoc(), dfltLabelItem,
/*HasBoundDecls=*/false, SourceLoc(),
dfltBody));
SourceLoc(), dfltBody));
auto *stringValueDecl = initDecl->getParameterList(1)->get(0);
auto *stringValueRef = new (C) DeclRefExpr(stringValueDecl, DeclNameLoc(),