Skip to content

Commit a24fe7c

Browse files
committed
[Concurrency] Suppress unsafe global variable warnings when the variable is from
a `@preconcurrency` import.
1 parent 75858cd commit a24fe7c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ namespace {
30553055
ctx.Diags.diagnose(loc, diag::shared_mutable_state_access, value)
30563056
.limitBehaviorUntilSwiftVersion(limit, 6)
30573057
// Preconcurrency global variables are warnings even in Swift 6
3058-
.limitBehaviorIf(isPreconcurrencyImport, DiagnosticBehavior::Warning);
3058+
.limitBehaviorIf(isPreconcurrencyImport, limit);
30593059
value->diagnose(diag::kind_declared_here, value->getDescriptiveKind());
30603060
if (const auto sourceFile = getDeclContext()->getParentSourceFile();
30613061
sourceFile && isPreconcurrencyImport) {

test/Concurrency/global_variables.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/GlobalVariables.swiftmodule -module-name GlobalVariables -parse-as-library -strict-concurrency=minimal -swift-version 5 %S/Inputs/GlobalVariables.swift
3-
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -swift-version 6 -I %t %s -emit-sil -o /dev/null -verify %s
3+
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -swift-version 6 -I %t -emit-sil -o /dev/null -verify %s
44

55
// REQUIRES: concurrency
66

@@ -71,7 +71,7 @@ func testLocalNonisolatedUnsafe() async {
7171

7272
func testImportedGlobals() { // expected-note{{add '@MainActor' to make global function 'testImportedGlobals()' part of global actor 'MainActor'}}
7373
let _ = Globals.integerConstant
74-
let _ = Globals.integerMutable // expected-warning{{reference to static property 'integerMutable' is not concurrency-safe because it involves shared mutable state}}
74+
let _ = Globals.integerMutable
7575
let _ = Globals.nonisolatedUnsafeIntegerConstant
7676
let _ = Globals.nonisolatedUnsafeIntegerMutable
7777
let _ = Globals.actorInteger // expected-error{{main actor-isolated static property 'actorInteger' can not be referenced from a non-isolated context}}

0 commit comments

Comments
 (0)