Skip to content

Commit 7e5a4f2

Browse files
authored
Merge pull request #31040 from apple/revert-30182-enum-cxx
Revert "Move out enum tests into a separate CXXInterop/enum directory"
2 parents 6e6761e + 0c63feb commit 7e5a4f2

File tree

12 files changed

+51
-54
lines changed

12 files changed

+51
-54
lines changed

test/CXXInterop/enum/Inputs/enum-anon.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/CXXInterop/enum/Inputs/module.map

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/CXXInterop/enum/enum-anon.swift

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/ClangImporter/Inputs/custom-modules/module.map

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ module ctypes_bits_exported {
4545
export *
4646
}
4747

48+
module EnumExhaustivity {
49+
header "EnumExhaustivity.h"
50+
export *
51+
}
52+
4853
module ExternIntX { header "x.h" }
4954

5055
module HasSubmodule {

test/ClangImporter/Inputs/enum-anon.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
enum {
2+
Constant1,
3+
Constant2
4+
};
5+
6+
enum {
7+
VarConstant1,
8+
VarConstant2
9+
} global;
10+
11+
typedef struct SR2511 {
12+
int x;
13+
14+
enum {
15+
SR2511A = 0, SR2511B, SR2511C
16+
} y;
17+
18+
int z;
19+
} SR2511;
20+
21+
#if __OBJC__
122
enum : unsigned short {
223
USConstant1,
324
USConstant2
@@ -7,3 +28,4 @@ enum : unsigned short {
728
USVarConstant1,
829
USVarConstant2
930
} usGlobal;
31+
#endif // __OBJC__

test/CXXInterop/enum/enum-anon-sized.swift renamed to test/ClangImporter/enum-anon-sized.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-ir %s -I %S/Inputs | %FileCheck -check-prefix=CHECK %s
2-
// RUN: %target-swift-frontend -emit-ir %s -I %S/Inputs -enable-cxx-interop | %FileCheck -check-prefix=CHECK %s
3-
4-
import EnumAnon
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
52

63
func verifyIsInt(_: inout Int) { }
74
func verifyIsInt32(_: inout Int32) { }
@@ -26,6 +23,11 @@ public func testIR(x: UnsafePointer<SR2511>) -> CInt {
2623
// CHECK: store i32 1, i32* getelementptr inbounds ([[ENUM_TYPE]], [[ENUM_TYPE]]* bitcast (i32* @global to [[ENUM_TYPE]]*), i32 0, i32 0), align 4
2724
global = VarConstant2
2825

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+
2931
// Force the definition of the type above.
3032
// CHECK: ret
3133
return x.pointee.z

test/ClangImporter/enum-anon.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
// RUN: %target-swift-frontend -typecheck %s -enable-objc-interop -import-objc-header %S/Inputs/enum-anon.h -DDIAGS -verify
22

3-
// REQUIRES: objc_interop
4-
53
func testDiags() {
4+
#if _runtime(_ObjC)
65
let us2 = USConstant2
6+
#else
7+
let us2: UInt16 = 0
8+
#endif
79
let _: String = us2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}}
10+
11+
#if _runtime(_ObjC)
812
let usVar2 = USVarConstant2
13+
#else
14+
let usVar2: UInt16 = 0
15+
#endif
916
let _: String = usVar2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}}
17+
18+
// The nested anonymous enum value should still have top-level scope, because
19+
// that's how C works. It should also have the same type as the field (above).
20+
let _: String = SR2511.SR2511B // expected-error {{type 'SR2511' has no member 'SR2511B'}}
1021
}
22+

test/CXXInterop/enum/enum-cxx.swift renamed to test/ClangImporter/enum-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/../../ClangImporter/Inputs/ -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/Inputs/custom-modules -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s
22

33
import CXXInterop
44

0 commit comments

Comments
 (0)