Skip to content

Commit 16cbb76

Browse files
authored
Merge pull request #69710 from Azoy/stdlib-warning-cleanup
[stdlib] Silence some standard library warnings
2 parents 2ef2659 + e41fe5a commit 16cbb76

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ func checkMacroDefinition(
255255
case "ExternalMacro":
256256
return Int(BridgedMacroDefinitionKind.builtinExternalMacro.rawValue)
257257

258+
// These builtins don't exist, but are put into the standard library at
259+
// least for documentation purposes right now. Don't emit a warning for
260+
// them, but do fail operation.
261+
case "FileIDMacro",
262+
"FilePathMacro",
263+
"FileMacro",
264+
"FunctionMacro",
265+
"LineMacro",
266+
"ColumnMacro",
267+
"DSOHandleMacro",
268+
"WarningMacro",
269+
"ErrorMacro":
270+
return -1
271+
258272
default:
259273
// Warn about the unknown builtin.
260274
let srcMgr = SourceManager(cxxDiagnosticEngine: diagEnginePtr)

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,17 @@ static void checkProtocolRefinementRequirements(ProtocolDecl *proto) {
20302030
// TODO(kavon): emit tailored error diagnostic to remove the ~Copyable
20312031
}
20322032

2033+
// SIMDScalar in the standard library currently emits this warning for:
2034+
// 'Hashable', 'Encodable', and 'Decodable'. This is unfortunate, but we
2035+
// cannot fix it as it would alter the ABI of the protocol. Silence these
2036+
// warnings specifically for those cases.
2037+
if (proto->isSpecificProtocol(KnownProtocolKind::SIMDScalar) &&
2038+
(otherProto->isSpecificProtocol(KnownProtocolKind::Hashable) ||
2039+
otherProto->isSpecificProtocol(KnownProtocolKind::Encodable) ||
2040+
otherProto->isSpecificProtocol(KnownProtocolKind::Decodable))) {
2041+
continue;
2042+
}
2043+
20332044
// GenericSignature::getRequiredProtocols() canonicalizes the protocol
20342045
// list by dropping protocols that are inherited by other protocols in
20352046
// the list. Any protocols that remain in the list other than 'proto'

stdlib/public/core/Macros.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ public macro warning(_ message: String) = Builtin.WarningMacro
7171
@freestanding(declaration)
7272
public macro error(_ message: String) = Builtin.ErrorMacro
7373

74-
#endif
74+
#endif // $Macros && hasAttribute(attached)

0 commit comments

Comments
 (0)