Skip to content

Commit ff4feee

Browse files
authored
Merge pull request #2450 from spevans/pr_unsupported_arch
Consistently add #error when compiling on unsupported architectures.
2 parents b2e3e37 + dae5ec1 commit ff4feee

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

Foundation/CGFloat.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public struct CGFloat {
1717
/// The native type used to store the CGFloat, which is Float on
1818
/// 32-bit architectures and Double on 64-bit architectures.
1919
public typealias NativeType = Double
20+
#else
21+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
2022
#endif
2123

2224
@_transparent public init() {
@@ -187,6 +189,8 @@ extension CGFloat : BinaryFloatingPoint {
187189
native = NativeType(bitPattern: UInt32(bitPattern))
188190
#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
189191
native = NativeType(bitPattern: UInt64(bitPattern))
192+
#else
193+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
190194
#endif
191195
}
192196

Foundation/Data.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,8 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
661661
@usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8,
662662
UInt8, UInt8) //len //enum
663663
@usableFromInline var bytes: Buffer
664+
#else
665+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
664666
#endif
665667
@usableFromInline var length: UInt8
666668

@@ -686,6 +688,8 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
686688
bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0))
687689
#elseif arch(i386) || arch(arm)
688690
bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0))
691+
#else
692+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
689693
#endif
690694
length = UInt8(count)
691695
}
@@ -867,6 +871,8 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
867871
@usableFromInline internal typealias HalfInt = Int32
868872
#elseif arch(i386) || arch(arm)
869873
@usableFromInline internal typealias HalfInt = Int16
874+
#else
875+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
870876
#endif
871877

872878
// A buffer of bytes too large to fit in an InlineData, but still small enough to fit a storage pointer + range in two words.

Foundation/NSNumber.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ open class NSNumber : NSValue {
718718
self.init(bytes: &value, numberType: kCFNumberSInt64Type)
719719
#elseif arch(i386) || arch(arm)
720720
self.init(bytes: &value, numberType: kCFNumberSInt32Type)
721+
#else
722+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
721723
#endif
722724
}
723725

@@ -733,6 +735,8 @@ open class NSNumber : NSValue {
733735
#elseif arch(i386) || arch(arm)
734736
var value = Int64(value)
735737
self.init(bytes: &value, numberType: kCFNumberSInt64Type)
738+
#else
739+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
736740
#endif
737741
}
738742

Foundation/NSRange.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ extension NSRange: NSSpecialValueCoding {
384384
#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
385385
return "{_NSRange=QQ}"
386386
#else
387-
NSUnimplemented()
387+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
388388
#endif
389389
}
390390

TestFoundation/TestNSNumber.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ class TestNSNumber : XCTestCase {
12301230
XCTAssertEqual("i" /* 0x71 */, objCType(NSNumber(value: Int.max)))
12311231
XCTAssertEqual("q" /* 0x71 */, objCType(NSNumber(value: UInt(Int.max))))
12321232
XCTAssertEqual("q" /* 0x51 */, objCType(NSNumber(value: UInt(Int.max) + 1)))
1233+
#else
1234+
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.")
12331235
#endif
12341236

12351237
XCTAssertEqual("f" /* 0x66 */, objCType(NSNumber(value: Float.greatestFiniteMagnitude)))

0 commit comments

Comments
 (0)