Skip to content

Commit 0c5cc38

Browse files
committed
Parse: Add fix-its for 'before:' label parse errors in the @_backDeploy attribute.
1 parent 2a646dc commit 0c5cc38

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,9 +1848,11 @@ bool Parser::parseBackDeployAttribute(DeclAttributes &Attributes,
18481848
if (Tok.is(tok::identifier) && Tok.getText() == "before") {
18491849
consumeToken();
18501850
if (!consumeIf(tok::colon))
1851-
diagnose(Tok, diag::attr_back_deploy_expected_colon_after_before);
1851+
diagnose(Tok, diag::attr_back_deploy_expected_colon_after_before)
1852+
.fixItInsertAfter(PreviousLoc, ":");
18521853
} else {
1853-
diagnose(Tok, diag::attr_back_deploy_expected_before_label);
1854+
diagnose(Tok, diag::attr_back_deploy_expected_before_label)
1855+
.fixItInsertAfter(PreviousLoc, "before:");
18541856
}
18551857

18561858
// Parse the version list.

test/attr/attr_backDeploy.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,23 +309,23 @@ public func knownAndUnknownMacroVersionned() {}
309309
public func emptyAttributeFunc() {}
310310

311311
@available(macOS 11.0, *)
312-
@_backDeploy(macOS 12.0) // expected-error {{expected 'before:' in '@_backDeploy' attribute}}
312+
@_backDeploy(macOS 12.0) // expected-error {{expected 'before:' in '@_backDeploy' attribute}} {{14-14=before:}}
313313
public func missingBeforeFunc() {}
314314

315-
@_backDeploy(before) // expected-error {{expected ':' after 'before' in '@_backDeploy' attribute}}
315+
@_backDeploy(before) // expected-error {{expected ':' after 'before' in '@_backDeploy' attribute}} {{20-20=:}}
316316
// expected-error@-1 {{expected at least one platform version in '@_backDeploy' attribute}}
317317
public func missingColonAfterBeforeFunc() {}
318318

319319
@available(macOS 11.0, *)
320-
@_backDeploy(before macOS 12.0) // expected-error {{expected ':' after 'before' in '@_backDeploy' attribute}}
320+
@_backDeploy(before macOS 12.0) // expected-error {{expected ':' after 'before' in '@_backDeploy' attribute}} {{20-20=:}}
321321
public func missingColonBetweenBeforeAndPlatformFunc() {}
322322

323323
@available(macOS 11.0, *)
324-
@_backDeploy(before: macOS 12.0,) // expected-error {{unexpected ',' separator}}
324+
@_backDeploy(before: macOS 12.0,) // expected-error {{unexpected ',' separator}} {{32-33=}}
325325
public func unexpectedTrailingCommaFunc() {}
326326

327327
@available(macOS 11.0, iOS 14.0, *)
328-
@_backDeploy(before: macOS 12.0,, iOS 15.0) // expected-error {{unexpected ',' separator}}
328+
@_backDeploy(before: macOS 12.0,, iOS 15.0) // expected-error {{unexpected ',' separator}} {{33-34=}}
329329
public func extraCommaFunc() {}
330330

331331
@_backDeploy(before:) // expected-error {{expected at least one platform version in '@_backDeploy' attribute}}

0 commit comments

Comments
 (0)