Skip to content

Commit e6a7e0d

Browse files
committed
Fix diagnostics when @warn_unused_result is used with other attrs
1 parent df68c08 commit e6a7e0d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
13581358
diagnose(AtLoc, diag::attr_warn_unused_result_removed)
13591359
.fixItRemove(SourceRange(AtLoc, attrLoc));
13601360

1361-
return true;
1361+
return false;
13621362
}
13631363

13641364
// @warn_unused_result with arguments.
@@ -1379,7 +1379,7 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
13791379
diagnose(AtLoc, diag::attr_warn_unused_result_removed)
13801380
.fixItRemove(SourceRange(AtLoc, rParenLoc));
13811381

1382-
return true;
1382+
return false;
13831383
}
13841384

13851385
if (DK != DAK_Count && !DeclAttribute::shouldBeRejectedByParser(DK))

test/attr/attr_discardableResult.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ func f(a : () -> Int) {
104104
}
105105

106106
@warn_unused_result func g() -> Int { } // expected-warning {{'warn_unused_result' attribute behavior is now the default}} {{1-21=}}
107+
108+
class X {
109+
@warn_unused_result // expected-warning {{'warn_unused_result' attribute behavior is now the default}} {{3-23=}}
110+
@objc
111+
func h() -> Int { }
112+
}

0 commit comments

Comments
 (0)