mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user