Skip to content

Commit 3914cdd

Browse files
authored
Merge pull request #77578 from tshortli/warnings
stdlib/Concurrency: Resolve or suppress a bunch of warnings
2 parents d1ef379 + 1ee4924 commit 3914cdd

File tree

14 files changed

+89
-36
lines changed

14 files changed

+89
-36
lines changed

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ import SwiftPrivate
4040
import SwiftPrivateLibcExtras
4141
import SwiftPrivateThreadExtras
4242
#if canImport(Darwin)
43-
import Darwin
43+
internal import Darwin
4444
#elseif canImport(Glibc)
45-
import Glibc
45+
internal import Glibc
4646
#elseif canImport(Musl)
47-
import Musl
47+
internal import Musl
4848
#elseif canImport(Android)
49-
import Android
49+
internal import Android
5050
#elseif os(WASI)
51-
import WASILibc
51+
internal import WASILibc
5252
#elseif os(Windows)
53-
import CRT
54-
import WinSDK
53+
internal import CRT
54+
internal import WinSDK
5555
#endif
5656

5757
#if _runtime(_ObjC)
58-
import ObjectiveC
58+
internal import ObjectiveC
5959
#else
6060
func autoreleasepool(invoking code: () -> Void) {
6161
// Native runtime does not have autorelease pools. Execute the code

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
import SwiftPrivate
1414
import SwiftPrivateLibcExtras
1515
#if canImport(Darwin)
16-
import Darwin
16+
internal import Darwin
1717
#elseif canImport(Glibc)
18-
import Glibc
18+
internal import Glibc
1919
#elseif canImport(Musl)
20-
import Musl
20+
internal import Musl
2121
#elseif canImport(Android)
22-
import Android
22+
internal import Android
2323
#elseif os(WASI)
24-
import WASILibc
24+
internal import WASILibc
2525
#elseif os(Windows)
26-
import CRT
26+
internal import CRT
2727
#endif
2828

2929
#if _runtime(_ObjC)
30-
import Foundation
30+
internal import Foundation
3131
#endif
3232

3333
//

stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ import SwiftPrivateLibcExtras
1717

1818
#if canImport(Darwin)
1919
#if _runtime(_ObjC)
20-
import Foundation
20+
internal import Foundation
2121
#endif
22-
import Darwin
23-
import var Darwin.errno
22+
internal import Darwin
23+
internal import var Darwin.errno
2424
#elseif canImport(Glibc)
25-
import Glibc
25+
internal import Glibc
2626
#elseif canImport(Musl)
27-
import Musl
27+
internal import Musl
2828
#elseif canImport(Android)
29-
import Android
29+
internal import Android
3030
#elseif os(WASI)
31-
import WASILibc
31+
internal import WASILibc
3232
#elseif os(Windows)
33-
import CRT
34-
import WinSDK
33+
internal import CRT
34+
internal import WinSDK
3535
#endif
3636

3737
#if _runtime(_ObjC)
38-
import ObjectiveC
38+
internal import ObjectiveC
3939
#endif
4040

4141
#if SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY

stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ let RequestPointerSize = "p"
2929

3030

3131
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
32-
import MachO
33-
import Darwin
34-
import var Darwin.errno
32+
internal import MachO
33+
internal import Darwin
34+
internal import var Darwin.errno
3535

3636
#if arch(x86_64) || arch(arm64)
3737
typealias MachHeader = mach_header_64

stdlib/public/Concurrency/Task.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ static void destroyTask(SWIFT_CONTEXT HeapObject *obj) {
364364
free(task);
365365
}
366366

367+
#if !SWIFT_CONCURRENCY_EMBEDDED
368+
367369
static SerialExecutorRef executorForEnqueuedJob(Job *job) {
368370
#if !SWIFT_CONCURRENCY_ENABLE_DISPATCH
369371
return SerialExecutorRef::generic();
@@ -392,8 +394,6 @@ static void jobInvoke(void *obj, void *unused, uint32_t flags) {
392394
// Magic constant to identify Swift Job vtables to Dispatch.
393395
static const unsigned long dispatchSwiftObjectType = 1;
394396

395-
#if !SWIFT_CONCURRENCY_EMBEDDED
396-
397397
static FullMetadata<DispatchClassMetadata> jobHeapMetadata = {
398398
{
399399
{
@@ -583,8 +583,11 @@ SWIFT_CC(swiftasync)
583583
static void task_wait_throwing_resume_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
584584

585585
auto context = static_cast<TaskFutureWaitAsyncContext *>(_context);
586+
#pragma clang diagnostic push
587+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
586588
auto resumeWithError =
587589
reinterpret_cast<AsyncVoidClosureEntryPoint *>(context->ResumeParent);
590+
#pragma clang diagnostic pop
588591
return resumeWithError(context->Parent, context->errorResult);
589592
}
590593

@@ -959,17 +962,23 @@ swift_task_create_commonImpl(size_t rawTaskCreateFlags,
959962
auto asyncContextPrefix = reinterpret_cast<AsyncContextPrefix *>(
960963
reinterpret_cast<char *>(allocation) + headerSize -
961964
sizeof(AsyncContextPrefix));
965+
#pragma clang diagnostic push
966+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
962967
asyncContextPrefix->asyncEntryPoint =
963968
reinterpret_cast<AsyncVoidClosureEntryPoint *>(function);
969+
#pragma clang diagnostic pop
964970
asyncContextPrefix->closureContext = closureContext;
965971
function = non_future_adapter;
966972
assert(sizeof(AsyncContextPrefix) == 3 * sizeof(void *));
967973
} else {
968974
auto asyncContextPrefix = reinterpret_cast<FutureAsyncContextPrefix *>(
969975
reinterpret_cast<char *>(allocation) + headerSize -
970976
sizeof(FutureAsyncContextPrefix));
977+
#pragma clang diagnostic push
978+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
971979
asyncContextPrefix->asyncEntryPoint =
972980
reinterpret_cast<AsyncGenericClosureEntryPoint *>(function);
981+
#pragma clang diagnostic pop
973982
function = future_adapter;
974983
asyncContextPrefix->closureContext = closureContext;
975984
assert(sizeof(FutureAsyncContextPrefix) == 4 * sizeof(void *));
@@ -1035,13 +1044,16 @@ swift_task_create_commonImpl(size_t rawTaskCreateFlags,
10351044
" with parent %p at base pri %zu",
10361045
task, task->getTaskId(), parent, basePriority);
10371046

1047+
#pragma clang diagnostic push
1048+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
10381049
// Initialize the task-local allocator.
10391050
initialContext->ResumeParent =
10401051
runInlineOption ? &completeInlineTask
10411052
: reinterpret_cast<TaskContinuationFunction *>(
10421053
asyncLet ? &completeTask
10431054
: closureContext ? &completeTaskWithClosure
10441055
: &completeTaskAndRelease);
1056+
#pragma clang diagnostic pop
10451057
if ((asyncLet || (runInlineOption && runInlineOption->getAllocation())) &&
10461058
initialSlabSize > 0) {
10471059
assert(parent || (runInlineOption && runInlineOption->getAllocation()));
@@ -1260,10 +1272,13 @@ AsyncTaskAndContext swift::swift_task_create(
12601272
FutureAsyncSignature,
12611273
SpecialPointerAuthDiscriminators::AsyncFutureFunction>(closureEntry);
12621274

1275+
#pragma clang diagnostic push
1276+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
12631277
return swift_task_create_common(
12641278
rawTaskCreateFlags, options, futureResultType,
12651279
reinterpret_cast<TaskContinuationFunction *>(taskEntry), closureContext,
12661280
initialContextSize);
1281+
#pragma clang diagnostic pop
12671282
}
12681283
}
12691284

@@ -1348,7 +1363,10 @@ void swift_task_future_wait_throwingImpl(
13481363
waitingTask->ResumeTask = task_wait_throwing_resume_adapter;
13491364
waitingTask->ResumeContext = callContext;
13501365

1366+
#pragma clang diagnostic push
1367+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
13511368
auto resumeFn = reinterpret_cast<TaskContinuationFunction *>(resumeFunction);
1369+
#pragma clang diagnostic pop
13521370

13531371
// Wait on the future.
13541372
assert(task->isFuture());

stdlib/public/runtime/Exclusivity.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static void reportExclusivityConflict(ExclusivityFlags oldAction, void *oldPC,
138138

139139
RuntimeErrorDetails::Thread secondaryThread = {
140140
.description = oldAccess,
141+
.threadID = 0,
141142
.numFrames = 1,
142143
.frames = &oldPC
143144
};
@@ -148,7 +149,11 @@ static void reportExclusivityConflict(ExclusivityFlags oldAction, void *oldPC,
148149
.framesToSkip = framesToSkip,
149150
.memoryAddress = pointer,
150151
.numExtraThreads = 1,
151-
.threads = &secondaryThread
152+
.threads = &secondaryThread,
153+
.numFixIts = 0,
154+
.fixIts = nullptr,
155+
.numNotes = 0,
156+
.notes = nullptr,
152157
};
153158
_swift_reportToDebugger(RuntimeErrorFlagFatal, message, &details);
154159
}

stdlib/public/runtime/Metadata.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7791,7 +7791,13 @@ diagnoseMetadataDependencyCycle(llvm::ArrayRef<MetadataDependency> links) {
77917791
.errorType = "type-metadata-cycle",
77927792
.currentStackDescription = "fetching metadata", // TODO?
77937793
.framesToSkip = 1, // skip out to the check function
7794-
.memoryAddress = links.front().Value
7794+
.memoryAddress = links.front().Value,
7795+
.numExtraThreads = 0,
7796+
.threads = nullptr,
7797+
.numFixIts = 0,
7798+
.fixIts = nullptr,
7799+
.numNotes = 0,
7800+
.notes = nullptr,
77957801
// TODO: describe the cycle using notes instead of one huge message?
77967802
};
77977803
#pragma GCC diagnostic pop

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ template<> void ProtocolConformanceDescriptor::dump() const {
134134
return "<unknown addr>";
135135
};
136136

137-
switch (auto kind = getTypeKind()) {
137+
switch (getTypeKind()) {
138138
case TypeReferenceKind::DirectObjCClassName:
139139
printf("direct Objective-C class name %s", getDirectObjCClassName());
140140
break;

stdlib/public/runtime/SwiftObject.mm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,13 @@ static bool isUniquelyReferenced(id object) {
16271627
.errorType = "escaping-closure-violation",
16281628
.currentStackDescription = "Closure has escaped",
16291629
.framesToSkip = 1,
1630+
.memoryAddress = nullptr,
1631+
.numExtraThreads = 0,
1632+
.threads = nullptr,
1633+
.numFixIts = 0,
1634+
.fixIts = nullptr,
1635+
.numNotes = 0,
1636+
.notes = nullptr,
16301637
};
16311638
_swift_reportToDebugger(RuntimeErrorFlagFatal, log, &details);
16321639
}
@@ -1728,7 +1735,13 @@ void swift_objc_swift3ImplicitObjCEntrypoint(id self, SEL selector,
17281735
RuntimeErrorDetails details = {
17291736
.version = RuntimeErrorDetails::currentVersion,
17301737
.errorType = "implicit-objc-entrypoint",
1738+
.currentStackDescription = nullptr,
17311739
.framesToSkip = 1,
1740+
.memoryAddress = nullptr,
1741+
.numExtraThreads = 0,
1742+
.threads = nullptr,
1743+
.numFixIts = 0,
1744+
.fixIts = nullptr,
17321745
.numNotes = 1,
17331746
.notes = &note
17341747
};

stdlib/toolchain/Compatibility50/Overrides.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ struct OverrideSection {
3030
Override_ ## name name;
3131
#include "CompatibilityOverride.def"
3232
};
33-
33+
34+
#pragma clang diagnostic push
35+
#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers"
3436
OverrideSection Swift50Overrides
3537
__attribute__((used, section("__DATA,__swift_hooks"))) = {
3638
.version = 0,
@@ -41,6 +43,7 @@ __attribute__((used, section("__DATA,__swift_hooks"))) = {
4143
// the Compatibility51 library is always linked when the 50 library is.
4244
.conformsToSwiftProtocol = swift51override_conformsToSwiftProtocol,
4345
};
46+
#pragma clang diagnostic pop
4447

4548
// Allow this library to get force-loaded by autolinking
4649
__attribute__((weak, visibility("hidden")))

stdlib/toolchain/Compatibility51/Overrides.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ struct OverrideSection {
2929
Override_ ## name name;
3030
#include "CompatibilityOverride.def"
3131
};
32-
32+
33+
#pragma clang diagnostic push
34+
#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers"
3335
OverrideSection Swift51Overrides
3436
__attribute__((used, section("__DATA,__swift51_hooks"))) = {
3537
.version = 0,
3638
.conformsToSwiftProtocol = swift51override_conformsToSwiftProtocol,
3739
};
40+
#pragma clang diagnostic pop
3841

3942
// Allow this library to get force-loaded by autolinking
4043
__attribute__((weak, visibility("hidden")))

stdlib/toolchain/Compatibility56/Overrides.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct ConcurrencyOverrideSection {
3939

4040
#undef OVERRIDE
4141

42+
#pragma clang diagnostic push
43+
#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers"
4244
__attribute__((visibility("hidden")))
4345
ConcurrencyOverrideSection Swift56ConcurrencyOverrides
4446
__attribute__((used, section("__DATA,__s_async_hook"))) = {
@@ -55,6 +57,7 @@ RuntimeOverrideSection Swift56RuntimeOverrides
5557
__attribute__((used, section("__DATA,__swift56_hooks"))) = {
5658
.version = 0,
5759
};
60+
#pragma clang diagnostic pop
5861

5962
// Allow this library to get force-loaded by autolinking
6063
__attribute__((weak, visibility("hidden")))

test/Interop/Cxx/templates/enable-if-typechecker.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import StdlibUnittest
55
import EnableIf
66

7+
78
let x = HasMethodWithEnableIf()
89
x.onlyEnabledForBool("a")
9-
// CHECK: error: could not substitute parameters for C++ function template 'HasMethodWithEnableIf::onlyEnabledForBool': NSString *
10+
// CHECK: error: could not generate C++ types from the generic Swift types provided; the following Swift type(s) provided to 'HasMethodWithEnableIf::onlyEnabledForBool' could not be converted: String

unittests/Threading/LockingHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void scopedUnlockUnderScopedLockThreaded(M &mutex) {
144144

145145
ASSERT_EQ(count1, 500);
146146
ASSERT_EQ(count2, 500);
147+
(void)badCount; // FIXME: Is this value meant to be tested?
147148
}
148149

149150
// Test a critical section

0 commit comments

Comments
 (0)