Skip to content

Commit 1b2da8c

Browse files
committed
Remove the #setline directive, which was formerly known as #line and is now
known as #sourceLocation. #setline was an intermediate but never endorsed state. Upgrade the migration diagnostics for SE-0066 and SE-0049 to be errors instead of warnings.
1 parent 45f2cfa commit 1b2da8c

File tree

9 files changed

+14
-23
lines changed

9 files changed

+14
-23
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ ERROR(missing_initializer_def,PointsToFirstBadToken,
828828
"initializer requires a body", ())
829829

830830
// Attributes
831-
WARNING(attr_decl_attr_now_on_type,none,
831+
ERROR(attr_decl_attr_now_on_type,none,
832832
"%0 is now an attribute on a parameter type, "
833833
"instead of on the parameter itself", (StringRef))
834834

@@ -2669,8 +2669,8 @@ ERROR(objc_invalid_with_generic_params,none,
26692669
ERROR(objc_convention_invalid,none,
26702670
"%0 is not representable in Objective-C, so it cannot be used"
26712671
" with '@convention(%1)'", (Type, StringRef))
2672-
WARNING(function_type_no_parens,none,
2673-
"single argument function types require parentheses", ())
2672+
ERROR(function_type_no_parens,none,
2673+
"single argument function types require parentheses", ())
26742674
NOTE(not_objc_empty_protocol_composition,none,
26752675
"'protocol<>' is not considered '@objc'; use 'AnyObject' instead", ())
26762676
NOTE(not_objc_protocol,none,

include/swift/Parse/Parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,8 @@ class Parser {
708708
DeclAttributes &Attributes);
709709

710710
ParserResult<IfConfigDecl> parseDeclIfConfig(ParseDeclOptions Flags);
711-
/// Parse a #line/#setline directive.
712-
/// 'isLine = true' indicates parsing #line instead of #setline
711+
/// Parse a #line/#sourceLocation directive.
712+
/// 'isLine = true' indicates parsing #line instead of #sourcelocation
713713
ParserStatus parseLineDirective(bool isLine = false);
714714

715715
void setLocalDiscriminator(ValueDecl *D);

include/swift/Parse/Tokens.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ POUND_KEYWORD(elseif)
190190
POUND_KEYWORD(endif)
191191
POUND_KEYWORD(keyPath)
192192
POUND_KEYWORD(line)
193-
POUND_KEYWORD(setline)
194193
POUND_KEYWORD(sourceLocation)
195194
POUND_KEYWORD(selector)
196195

lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,6 @@ static bool isKeywordPossibleDeclStart(const Token &Tok) {
17361736
case tok::kw_var:
17371737
case tok::pound_if:
17381738
case tok::identifier:
1739-
case tok::pound_setline:
17401739
case tok::pound_sourceLocation:
17411740
return true;
17421741
case tok::pound_line:
@@ -2158,7 +2157,6 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
21582157
Status = parseLineDirective(false);
21592158
break;
21602159
case tok::pound_line:
2161-
case tok::pound_setline:
21622160
Status = parseLineDirective(true);
21632161
break;
21642162

lib/Parse/ParseStmt.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ bool Parser::isStartOfStmt() {
4747
case tok::kw_case:
4848
case tok::kw_default:
4949
case tok::pound_if:
50-
case tok::pound_setline:
5150
case tok::pound_sourceLocation:
5251
return true;
5352

@@ -292,8 +291,7 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
292291
// Parse the decl, stmt, or expression.
293292
PreviousHadSemi = false;
294293
if (isStartOfDecl()
295-
&& Tok.isNot(tok::pound_if, tok::pound_setline,
296-
tok::pound_sourceLocation)) {
294+
&& Tok.isNot(tok::pound_if, tok::pound_sourceLocation)) {
297295
ParserStatus Status =
298296
parseDecl(IsTopLevel ? PD_AllowTopLevel : PD_Default,
299297
[&](Decl *D) {TmpDecls.push_back(D);});
@@ -347,7 +345,7 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
347345
Entries.push_back(Entry);
348346
}
349347

350-
} else if (Tok.isAny(tok::pound_line, tok::pound_setline)) {
348+
} else if (Tok.is(tok::pound_line)) {
351349
ParserStatus Status = parseLineDirective(true);
352350
BraceItemsStatus |= Status;
353351
NeedParseErrorRecovery = Status.isError();
@@ -570,7 +568,6 @@ ParserResult<Stmt> Parser::parseStmt() {
570568
if (tryLoc.isValid()) diagnose(tryLoc, diag::try_on_stmt, Tok.getText());
571569
return parseStmtIfConfig();
572570
case tok::pound_line:
573-
case tok::pound_setline:
574571
if (LabelInfo) diagnose(LabelInfo.Loc, diag::invalid_label_on_stmt);
575572
if (tryLoc.isValid()) diagnose(tryLoc, diag::try_on_stmt, Tok.getText());
576573
return parseLineDirective(true);

test/Parse/line-directive.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,3 @@ public struct S { // expected-note{{in declaration of 'S'}}
3131

3232
#sourceLocation()
3333

34-
35-
// expected-error@+1{{#line directive was renamed to #sourceLocation}}
36-
#setline 32000 "troops_on_the_water"

test/attr/attr_autoclosure.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct AutoclosureEscapeTest {
6868
}
6969

7070
// @autoclosure(escaping)
71-
// expected-warning @+1 {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{13-34=}} {{38-38=@autoclosure(escaping) }}
71+
// expected-error @+1 {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{13-34=}} {{38-38=@autoclosure(escaping) }}
7272
func func10(@autoclosure(escaping _: () -> ()) { } // expected-error{{expected ')' in @autoclosure}}
7373
// expected-note@-1{{to match this opening '('}}
7474
@@ -123,9 +123,9 @@ let _ : (@autoclosure(escaping) -> ()) -> () // expected-error {{use of undecla
123123

124124

125125
// Migration
126-
// expected-warning @+1 {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{16-28=}} {{32-32=@autoclosure }}
126+
// expected-error @+1 {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{16-28=}} {{32-32=@autoclosure }}
127127
func migrateAC(@autoclosure _: () -> ()) { }
128128

129-
// expected-warning @+1 {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{17-39=}} {{43-43=@autoclosure(escaping) }}
129+
// expected-error @+1 {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{17-39=}} {{43-43=@autoclosure(escaping) }}
130130
func migrateACE(@autoclosure(escaping) _: () -> ()) { }
131131

test/attr/attr_noescape.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ enum r19997577Type {
296296
}
297297

298298
// type attribute and decl attribute
299-
func noescapeD(@noescape f: () -> Bool) {} // expected-warning {{@noescape is now an attribute on a parameter type, instead of on the parameter itself}} {{16-25=}} {{29-29=@noescape }}
299+
func noescapeD(@noescape f: () -> Bool) {} // expected-error {{@noescape is now an attribute on a parameter type, instead of on the parameter itself}} {{16-25=}} {{29-29=@noescape }}
300300
func noescapeT(f: @noescape () -> Bool) {} // ok
301-
func autoclosureD(@autoclosure f: () -> Bool) {} // expected-warning {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{19-31=}} {{35-35=@autoclosure }}
301+
func autoclosureD(@autoclosure f: () -> Bool) {} // expected-error {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{19-31=}} {{35-35=@autoclosure }}
302302
func autoclosureT(f: @autoclosure () -> Bool) {} // ok
303303

304304
func noescapeD_noescapeT(@noescape f: @noescape () -> Bool) {}
305-
func autoclosureD_noescapeT(@autoclosure f: @noescape () -> Bool) {} // expected-warning {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{29-41=}} {{45-45=@autoclosure }}
305+
func autoclosureD_noescapeT(@autoclosure f: @noescape () -> Bool) {} // expected-error {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{29-41=}} {{45-45=@autoclosure }}

test/type/types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class r21949448 {
157157
}
158158

159159
// SE-0066 - Standardize function type argument syntax to require parentheses
160-
let _ : Int -> Float // expected-warning {{single argument function types require parentheses}} {{9-9=(}} {{12-12=)}}
160+
let _ : Int -> Float // expected-error {{single argument function types require parentheses}} {{9-9=(}} {{12-12=)}}
161161

162162

163163

0 commit comments

Comments
 (0)