Skip to content

Commit 184b150

Browse files
committed
Allow the @Concurrent function attribute without the concurrency flag
1 parent e8375e1 commit 184b150

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

include/swift/AST/Attr.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
602602
106)
603603

604604
SIMPLE_DECL_ATTR(concurrent, Concurrent,
605-
OnFunc | OnConstructor | OnAccessor | ConcurrencyOnly |
606-
ABIStableToAdd | ABIStableToRemove |
605+
OnFunc | OnConstructor | OnAccessor |
606+
ABIBreakingToAdd | ABIBreakingToRemove |
607607
APIBreakingToAdd | APIBreakingToRemove,
608608
107)
609609

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,17 +2339,7 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
23392339
}
23402340
}
23412341

2342-
bool concurrent = false;
2343-
if (attrs.has(TAK_concurrent)) {
2344-
if (getASTContext().LangOpts.EnableExperimentalConcurrency) {
2345-
concurrent = true;
2346-
} else {
2347-
diagnoseInvalid(repr, attrs.getLoc(TAK_concurrent),
2348-
diag::attr_requires_concurrency,
2349-
TypeAttributes::getAttrName(TAK_concurrent),
2350-
false);
2351-
}
2352-
}
2342+
bool concurrent = attrs.has(TAK_concurrent);
23532343

23542344
ty = resolveASTFunctionType(fnRepr, options, rep, /*noescape=*/false,
23552345
concurrent, parsedClangFunctionType,

test/IDE/complete_decl_attribute.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct MyStruct {}
7171
// KEYWORD2-NEXT: Keyword/None: derivative[#Func Attribute#]; name=derivative
7272
// KEYWORD2-NEXT: Keyword/None: transpose[#Func Attribute#]; name=transpose
7373
// KEYWORD2-NEXT: Keyword/None: noDerivative[#Func Attribute#]; name=noDerivative
74+
// KEYWORD2-NEXT: Keyword/None: concurrent[#Func Attribute#]; name=concurrent
7475
// KEYWORD2-NOT: Keyword
7576
// KEYWORD2: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
7677
// KEYWORD2: End completions
@@ -190,6 +191,7 @@ struct _S {
190191
// ON_METHOD-DAG: Keyword/None: differentiable[#Func Attribute#]; name=differentiable
191192
// ON_METHOD-DAG: Keyword/None: derivative[#Func Attribute#]; name=derivative
192193
// ON_METHOD-DAG: Keyword/None: transpose[#Func Attribute#]; name=transpose
194+
// ON_METHOD-DAG: Keyword/None: concurrent[#Func Attribute#]; name=concurrent
193195
// ON_METHOD-DAG: Keyword/None: noDerivative[#Func Attribute#]; name=noDerivative
194196
// ON_METHOD-NOT: Keyword
195197
// ON_METHOD: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
@@ -251,6 +253,7 @@ struct _S {
251253
// ON_MEMBER_LAST-DAG: Keyword/None: derivative[#Declaration Attribute#]; name=derivative
252254
// ON_MEMBER_LAST-DAG: Keyword/None: transpose[#Declaration Attribute#]; name=transpose
253255
// ON_MEMBER_LAST-DAG: Keyword/None: noDerivative[#Declaration Attribute#]; name=noDerivative
256+
// ON_MEMBER_LAST-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent
254257
// ON_MEMBER_LAST-NOT: Keyword
255258
// ON_MEMBER_LAST: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
256259
// ON_MEMBER_LAST-NOT: Decl[PrecedenceGroup]
@@ -300,6 +303,7 @@ func dummy2() {}
300303
// KEYWORD_LAST-NEXT: Keyword/None: derivative[#Declaration Attribute#]; name=derivative
301304
// KEYWORD_LAST-NEXT: Keyword/None: transpose[#Declaration Attribute#]; name=transpose
302305
// KEYWORD_LAST-NEXT: Keyword/None: noDerivative[#Declaration Attribute#]; name=noDerivative
306+
// KEYWORD_LAST-NEXT: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent
303307
// KEYWORD_LAST-NOT: Keyword
304308
// KEYWORD_LAST: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
305309
// KEYWORD_LAST: End completions

test/attr/attr_concurrent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -typecheck -verify %s -enable-experimental-concurrency -enable-experimental-flow-sensitive-concurrent-captures
1+
// RUN: %target-swift-frontend -typecheck -verify %s -enable-experimental-flow-sensitive-concurrent-captures
22
// REQUIRES: concurrency
33

44
// Concurrent attribute on a function type.

0 commit comments

Comments
 (0)