Skip to content

Commit 1a57377

Browse files
authored
Merge pull request #16055 from rintaro/ast-breakcontinue-target
[AST] Initialize Target of break/continue with nullptr
2 parents c3f4d99 + b984789 commit 1a57377

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

include/swift/AST/Stmt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ class BreakStmt : public Stmt {
10231023
SourceLoc Loc;
10241024
Identifier TargetName; // Named target statement, if specified in the source.
10251025
SourceLoc TargetLoc;
1026-
LabeledStmt *Target; // Target stmt, wired up by Sema.
1026+
LabeledStmt *Target = nullptr; // Target stmt, wired up by Sema.
10271027
public:
10281028
BreakStmt(SourceLoc Loc, Identifier TargetName, SourceLoc TargetLoc,
10291029
Optional<bool> implicit = None)
@@ -1058,7 +1058,7 @@ class ContinueStmt : public Stmt {
10581058
SourceLoc Loc;
10591059
Identifier TargetName; // Named target statement, if specified in the source.
10601060
SourceLoc TargetLoc;
1061-
LabeledStmt *Target;
1061+
LabeledStmt *Target = nullptr;
10621062

10631063
public:
10641064
ContinueStmt(SourceLoc Loc, Identifier TargetName, SourceLoc TargetLoc,

test/refactoring/RefactoringKind/crashers.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ func foo() {
1111
// RUN: %refactor -source-filename %s -pos=6:5 -end-pos=6:13 | %FileCheck %s -check-prefix=CHECK1
1212
// RUN: %refactor -source-filename %s -pos=8:1 -end-pos=8:13 | %FileCheck %s -check-prefix=CHECK1
1313
// CHECK1: Action begins
14+
15+
// rdar://33972653
16+
func test() {
17+
break FOO
18+
continue FOO
19+
}
20+
21+
// RUN: %refactor -source-filename %s -pos=17:3 -end-pos=18:15 | %FileCheck %s -check-prefix=CHECK2
22+
// CHECK2: Action begins

0 commit comments

Comments
 (0)