Skip to content

Commit a54f57a

Browse files
committed
test: split up ClangImporter.enum-anon
This splits up the test into two halves in order to allow the test to pass on Windows. Loosen the test to allow the enumeration to be imported with signed and unsigned types as Windows uses signed enumerations by default.
1 parent e7aee37 commit a54f57a

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -enable-objc-interop -import-objc-header %S/Inputs/enum-anon.h | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-runtime %s
2+
3+
func verifyIsInt(_: inout Int) { }
4+
func verifyIsInt32(_: inout Int32) { }
5+
func verifyIsUInt32(_: inout UInt32) { }
6+
7+
var a = Constant2
8+
var b = VarConstant2
9+
var c = SR2511().y
10+
11+
verifyIsInt(&a)
12+
#if !os(Windows)
13+
verifyIsUInt32(&b)
14+
verifyIsUInt32(&c)
15+
#else
16+
verifyIsInt32(&b)
17+
verifyIsInt32(&c)
18+
#endif
19+
20+
// CHECK: %TSo6SR2511V = type <{ %Ts5Int32V, [[ENUM_TYPE:%Ts5Int32V|%Ts6UInt32V]], %Ts5Int32V }>
21+
// CHECK-LABEL: define{{.*}} i32 @"$s4main6testIR1xs5Int32VSPySo6SR2511VG_tF"(
22+
public func testIR(x: UnsafePointer<SR2511>) -> CInt {
23+
// CHECK: store i32 1, i32* getelementptr inbounds ([[ENUM_TYPE]], [[ENUM_TYPE]]* bitcast (i32* @global to [[ENUM_TYPE]]*), i32 0, i32 0), align 4
24+
global = VarConstant2
25+
26+
#if _runtime(_ObjC)
27+
// CHECK-objc: store i16 1, i16* getelementptr inbounds (%Ts6UInt16V, %Ts6UInt16V* bitcast (i16* @usGlobal to %Ts6UInt16V*), i32 0, i32 0), align 2
28+
usGlobal = USVarConstant2
29+
#endif
30+
31+
// Force the definition of the type above.
32+
// CHECK: ret
33+
return x.pointee.z
34+
} // CHECK-NEXT: {{^}$}}
35+

test/ClangImporter/enum-anon.swift

-24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// RUN: %target-swift-frontend -typecheck %s -enable-objc-interop -import-objc-header %S/Inputs/enum-anon.h -DDIAGS -verify
2-
// RUN: %target-swift-frontend -emit-ir %s -enable-objc-interop -import-objc-header %S/Inputs/enum-anon.h | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-runtime %s
32

4-
#if DIAGS
53
func testDiags() {
6-
let _: String = Constant2 // expected-error {{cannot convert value of type 'Int' to specified type 'String'}}
7-
let _: String = VarConstant2 // expected-error {{cannot convert value of type 'UInt32' to specified type 'String'}}
8-
94
#if _runtime(_ObjC)
105
let us2 = USConstant2
116
#else
@@ -20,27 +15,8 @@ func testDiags() {
2015
#endif
2116
let _: String = usVar2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}}
2217

23-
let _: String = SR2511().y // expected-error {{cannot convert value of type 'UInt32' to specified type 'String'}}
24-
2518
// The nested anonymous enum value should still have top-level scope, because
2619
// that's how C works. It should also have the same type as the field (above).
27-
let _: String = SR2511B // expected-error {{cannot convert value of type 'UInt32' to specified type 'String'}}
2820
let _: String = SR2511.SR2511B // expected-error {{type 'SR2511' has no member 'SR2511B'}}
2921
}
30-
#endif
31-
32-
// CHECK-LABEL: %TSo6SR2511V = type <{ %Ts5Int32V, %Ts6UInt32V, %Ts5Int32V }>
33-
// CHECK-LABEL: define{{.*}} i32 @"$s4main6testIR1xs5Int32VSPySo6SR2511VG_tF"(
34-
public func testIR(x: UnsafePointer<SR2511>) -> CInt {
35-
// CHECK: store i32 1, i32* getelementptr inbounds (%Ts6UInt32V, %Ts6UInt32V* bitcast (i32* @global to %Ts6UInt32V*), i32 0, i32 0), align 4
36-
global = VarConstant2
37-
38-
#if _runtime(_ObjC)
39-
// CHECK-objc: store i16 1, i16* getelementptr inbounds (%Ts6UInt16V, %Ts6UInt16V* bitcast (i16* @usGlobal to %Ts6UInt16V*), i32 0, i32 0), align 2
40-
usGlobal = USVarConstant2
41-
#endif
4222

43-
// Force the definition of the type above.
44-
// CHECK: ret
45-
return x.pointee.z
46-
} // CHECK-NEXT: {{^}$}}

0 commit comments

Comments
 (0)