diff --git a/test/CXXInterop/enum/Inputs/enum-anon.h b/test/CXXInterop/enum/Inputs/enum-anon.h deleted file mode 100644 index 3379a60747a93..0000000000000 --- a/test/CXXInterop/enum/Inputs/enum-anon.h +++ /dev/null @@ -1,19 +0,0 @@ -enum { - Constant1, - Constant2 -}; - -enum { - VarConstant1, - VarConstant2 -} global; - -typedef struct SR2511 { - int x; - - enum { - SR2511A = 0, SR2511B, SR2511C - } y; - - int z; -} SR2511; diff --git a/test/CXXInterop/enum/Inputs/module.map b/test/CXXInterop/enum/Inputs/module.map deleted file mode 100644 index 71f48fffcc0c8..0000000000000 --- a/test/CXXInterop/enum/Inputs/module.map +++ /dev/null @@ -1,8 +0,0 @@ -module EnumAnon { - header "enum-anon.h" -} - -module EnumExhaustivity { - header "EnumExhaustivity.h" - export * -} diff --git a/test/CXXInterop/enum/enum-anon.swift b/test/CXXInterop/enum/enum-anon.swift deleted file mode 100644 index 1933a84326afd..0000000000000 --- a/test/CXXInterop/enum/enum-anon.swift +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs -DDIAGS -verify -// RUN: %target-swift-frontend -typecheck %s -enable-cxx-interop -I %S/Inputs -DDIAGS -verify -import EnumAnon - -func testDiags() { - - let us2: UInt16 = 0 - let _: String = us2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}} - - let usVar2: UInt16 = 0 - let _: String = usVar2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}} - - // The nested anonymous enum value should still have top-level scope, because - // that's how C works. It should also have the same type as the field (above). - let _: String = SR2511.SR2511B // expected-error {{type 'SR2511' has no member 'SR2511B'}} -} - diff --git a/test/CXXInterop/enum/Inputs/EnumExhaustivity.apinotes b/test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.apinotes similarity index 100% rename from test/CXXInterop/enum/Inputs/EnumExhaustivity.apinotes rename to test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.apinotes diff --git a/test/CXXInterop/enum/Inputs/EnumExhaustivity.h b/test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.h similarity index 100% rename from test/CXXInterop/enum/Inputs/EnumExhaustivity.h rename to test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.h diff --git a/test/ClangImporter/Inputs/custom-modules/module.map b/test/ClangImporter/Inputs/custom-modules/module.map index 6d4fec580afa8..6c4612efb44c0 100644 --- a/test/ClangImporter/Inputs/custom-modules/module.map +++ b/test/ClangImporter/Inputs/custom-modules/module.map @@ -45,6 +45,11 @@ module ctypes_bits_exported { export * } +module EnumExhaustivity { + header "EnumExhaustivity.h" + export * +} + module ExternIntX { header "x.h" } module HasSubmodule { diff --git a/test/ClangImporter/Inputs/enum-anon.h b/test/ClangImporter/Inputs/enum-anon.h index 43fa6a9057f6d..ae48c3bc4dcd7 100644 --- a/test/ClangImporter/Inputs/enum-anon.h +++ b/test/ClangImporter/Inputs/enum-anon.h @@ -1,3 +1,24 @@ +enum { + Constant1, + Constant2 +}; + +enum { + VarConstant1, + VarConstant2 +} global; + +typedef struct SR2511 { + int x; + + enum { + SR2511A = 0, SR2511B, SR2511C + } y; + + int z; +} SR2511; + +#if __OBJC__ enum : unsigned short { USConstant1, USConstant2 @@ -7,3 +28,4 @@ enum : unsigned short { USVarConstant1, USVarConstant2 } usGlobal; +#endif // __OBJC__ diff --git a/test/CXXInterop/enum/enum-anon-sized.swift b/test/ClangImporter/enum-anon-sized.swift similarity index 67% rename from test/CXXInterop/enum/enum-anon-sized.swift rename to test/ClangImporter/enum-anon-sized.swift index 0f2c837882a87..3d63183094dcb 100644 --- a/test/CXXInterop/enum/enum-anon-sized.swift +++ b/test/ClangImporter/enum-anon-sized.swift @@ -1,7 +1,4 @@ -// RUN: %target-swift-frontend -emit-ir %s -I %S/Inputs | %FileCheck -check-prefix=CHECK %s -// RUN: %target-swift-frontend -emit-ir %s -I %S/Inputs -enable-cxx-interop | %FileCheck -check-prefix=CHECK %s - -import EnumAnon +// 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 func verifyIsInt(_: inout Int) { } func verifyIsInt32(_: inout Int32) { } @@ -26,6 +23,11 @@ public func testIR(x: UnsafePointer) -> CInt { // CHECK: store i32 1, i32* getelementptr inbounds ([[ENUM_TYPE]], [[ENUM_TYPE]]* bitcast (i32* @global to [[ENUM_TYPE]]*), i32 0, i32 0), align 4 global = VarConstant2 +#if _runtime(_ObjC) + // CHECK-objc: store i16 1, i16* getelementptr inbounds (%Ts6UInt16V, %Ts6UInt16V* bitcast (i16* @usGlobal to %Ts6UInt16V*), i32 0, i32 0), align 2 + usGlobal = USVarConstant2 +#endif + // Force the definition of the type above. // CHECK: ret return x.pointee.z diff --git a/test/ClangImporter/enum-anon.swift b/test/ClangImporter/enum-anon.swift index d87f930bf2faa..14e2baa7cca15 100644 --- a/test/ClangImporter/enum-anon.swift +++ b/test/ClangImporter/enum-anon.swift @@ -1,10 +1,22 @@ // RUN: %target-swift-frontend -typecheck %s -enable-objc-interop -import-objc-header %S/Inputs/enum-anon.h -DDIAGS -verify -// REQUIRES: objc_interop - func testDiags() { +#if _runtime(_ObjC) let us2 = USConstant2 +#else + let us2: UInt16 = 0 +#endif let _: String = us2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}} + +#if _runtime(_ObjC) let usVar2 = USVarConstant2 +#else + let usVar2: UInt16 = 0 +#endif let _: String = usVar2 // expected-error {{cannot convert value of type 'UInt16' to specified type 'String'}} + + // The nested anonymous enum value should still have top-level scope, because + // that's how C works. It should also have the same type as the field (above). + let _: String = SR2511.SR2511B // expected-error {{type 'SR2511' has no member 'SR2511B'}} } + diff --git a/test/CXXInterop/enum/enum-cxx.swift b/test/ClangImporter/enum-cxx.swift similarity index 71% rename from test/CXXInterop/enum/enum-cxx.swift rename to test/ClangImporter/enum-cxx.swift index dfd1d7725f164..281e31e3dc6f1 100644 --- a/test/CXXInterop/enum/enum-cxx.swift +++ b/test/ClangImporter/enum-cxx.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/../../ClangImporter/Inputs/ -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s +// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/Inputs/custom-modules -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s import CXXInterop diff --git a/test/CXXInterop/enum/enum-exhaustivity-system.swift b/test/ClangImporter/enum-exhaustivity-system.swift similarity index 94% rename from test/CXXInterop/enum/enum-exhaustivity-system.swift rename to test/ClangImporter/enum-exhaustivity-system.swift index b0547b5287648..3e54e5aabc0ea 100644 --- a/test/CXXInterop/enum/enum-exhaustivity-system.swift +++ b/test/ClangImporter/enum-exhaustivity-system.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -typecheck %s -Xcc -isystem -Xcc %S/Inputs -verify -enable-nonfrozen-enum-exhaustivity-diagnostics +// RUN: %target-swift-frontend -typecheck %s -Xcc -isystem -Xcc %S/Inputs/custom-modules -verify -enable-nonfrozen-enum-exhaustivity-diagnostics import EnumExhaustivity diff --git a/test/CXXInterop/enum/enum-exhaustivity.swift b/test/ClangImporter/enum-exhaustivity.swift similarity index 86% rename from test/CXXInterop/enum/enum-exhaustivity.swift rename to test/ClangImporter/enum-exhaustivity.swift index a3d342ce1816d..362b84601ca1b 100644 --- a/test/CXXInterop/enum/enum-exhaustivity.swift +++ b/test/ClangImporter/enum-exhaustivity.swift @@ -1,6 +1,6 @@ -// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs -verify -warnings-as-errors -enable-nonfrozen-enum-exhaustivity-diagnostics +// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs/custom-modules -verify -warnings-as-errors -enable-nonfrozen-enum-exhaustivity-diagnostics -// RUN: %target-swift-ide-test -source-filename %s -print-module -module-to-print EnumExhaustivity -I %S/Inputs | %FileCheck %s +// RUN: %target-swift-ide-test -source-filename %s -print-module -module-to-print EnumExhaustivity -I %S/Inputs/custom-modules | %FileCheck %s // CHECK-LABEL: {{^}}enum RegularEnum : {{.+}} { // CHECK: case A