Skip to content

Commit a10194c

Browse files
committed
Ensure that we don't diagnose the lack of initializer for @_extern variables
1 parent 5b642f5 commit a10194c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,10 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
25892589
if (!var->hasStorage())
25902590
return;
25912591

2592+
// If the variable is @_extern, it never needs an initializer.
2593+
if (var->getAttrs().hasAttribute<ExternAttr>())
2594+
return;
2595+
25922596
if (var->getAttrs().hasAttribute<SILGenNameAttr>()
25932597
|| !ABIRoleInfo(var).providesAPI())
25942598
return;

test/attr/attr_extern.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ struct StructScopeC {
7373

7474
@_extern(c, "static_member_decl")
7575
static func staticMemberDecl()
76+
77+
@_extern(c, "global_static_variable")
78+
static var globalVariable: Int
7679
}
7780

7881
struct GenericStruct<T> {

0 commit comments

Comments
 (0)