diff --git a/test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.apinotes b/test/CXXInterop/enum/Inputs/EnumExhaustivity.apinotes similarity index 100% rename from test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.apinotes rename to test/CXXInterop/enum/Inputs/EnumExhaustivity.apinotes diff --git a/test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.h b/test/CXXInterop/enum/Inputs/EnumExhaustivity.h similarity index 100% rename from test/ClangImporter/Inputs/custom-modules/EnumExhaustivity.h rename to test/CXXInterop/enum/Inputs/EnumExhaustivity.h diff --git a/test/CXXInterop/enum/Inputs/enum-anon.h b/test/CXXInterop/enum/Inputs/enum-anon.h new file mode 100644 index 0000000000000..3379a60747a93 --- /dev/null +++ b/test/CXXInterop/enum/Inputs/enum-anon.h @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000000..71f48fffcc0c8 --- /dev/null +++ b/test/CXXInterop/enum/Inputs/module.map @@ -0,0 +1,8 @@ +module EnumAnon { + header "enum-anon.h" +} + +module EnumExhaustivity { + header "EnumExhaustivity.h" + export * +} diff --git a/test/ClangImporter/enum-anon-sized.swift b/test/CXXInterop/enum/enum-anon-sized.swift similarity index 67% rename from test/ClangImporter/enum-anon-sized.swift rename to test/CXXInterop/enum/enum-anon-sized.swift index 3d63183094dcb..0f2c837882a87 100644 --- a/test/ClangImporter/enum-anon-sized.swift +++ b/test/CXXInterop/enum/enum-anon-sized.swift @@ -1,4 +1,7 @@ -// 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 +// 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 func verifyIsInt(_: inout Int) { } func verifyIsInt32(_: inout Int32) { } @@ -23,11 +26,6 @@ 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/CXXInterop/enum/enum-anon.swift b/test/CXXInterop/enum/enum-anon.swift new file mode 100644 index 0000000000000..1933a84326afd --- /dev/null +++ b/test/CXXInterop/enum/enum-anon.swift @@ -0,0 +1,17 @@ +// 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/ClangImporter/enum-cxx.swift b/test/CXXInterop/enum/enum-cxx.swift similarity index 71% rename from test/ClangImporter/enum-cxx.swift rename to test/CXXInterop/enum/enum-cxx.swift index 281e31e3dc6f1..dfd1d7725f164 100644 --- a/test/ClangImporter/enum-cxx.swift +++ b/test/CXXInterop/enum/enum-cxx.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/Inputs/custom-modules -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s +// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/../../ClangImporter/Inputs/ -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s import CXXInterop diff --git a/test/ClangImporter/enum-exhaustivity-system.swift b/test/CXXInterop/enum/enum-exhaustivity-system.swift similarity index 94% rename from test/ClangImporter/enum-exhaustivity-system.swift rename to test/CXXInterop/enum/enum-exhaustivity-system.swift index 3e54e5aabc0ea..b0547b5287648 100644 --- a/test/ClangImporter/enum-exhaustivity-system.swift +++ b/test/CXXInterop/enum/enum-exhaustivity-system.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -typecheck %s -Xcc -isystem -Xcc %S/Inputs/custom-modules -verify -enable-nonfrozen-enum-exhaustivity-diagnostics +// RUN: %target-swift-frontend -typecheck %s -Xcc -isystem -Xcc %S/Inputs -verify -enable-nonfrozen-enum-exhaustivity-diagnostics import EnumExhaustivity diff --git a/test/ClangImporter/enum-exhaustivity.swift b/test/CXXInterop/enum/enum-exhaustivity.swift similarity index 86% rename from test/ClangImporter/enum-exhaustivity.swift rename to test/CXXInterop/enum/enum-exhaustivity.swift index 362b84601ca1b..a3d342ce1816d 100644 --- a/test/ClangImporter/enum-exhaustivity.swift +++ b/test/CXXInterop/enum/enum-exhaustivity.swift @@ -1,6 +1,6 @@ -// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs/custom-modules -verify -warnings-as-errors -enable-nonfrozen-enum-exhaustivity-diagnostics +// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs -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/custom-modules | %FileCheck %s +// RUN: %target-swift-ide-test -source-filename %s -print-module -module-to-print EnumExhaustivity -I %S/Inputs | %FileCheck %s // CHECK-LABEL: {{^}}enum RegularEnum : {{.+}} { // CHECK: case A diff --git a/test/ClangImporter/Inputs/custom-modules/module.map b/test/ClangImporter/Inputs/custom-modules/module.map index b66f030963f97..75e12a49a29d4 100644 --- a/test/ClangImporter/Inputs/custom-modules/module.map +++ b/test/ClangImporter/Inputs/custom-modules/module.map @@ -45,11 +45,6 @@ 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 ae48c3bc4dcd7..43fa6a9057f6d 100644 --- a/test/ClangImporter/Inputs/enum-anon.h +++ b/test/ClangImporter/Inputs/enum-anon.h @@ -1,24 +1,3 @@ -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 @@ -28,4 +7,3 @@ enum : unsigned short { USVarConstant1, USVarConstant2 } usGlobal; -#endif // __OBJC__ diff --git a/test/ClangImporter/enum-anon.swift b/test/ClangImporter/enum-anon.swift index 14e2baa7cca15..d87f930bf2faa 100644 --- a/test/ClangImporter/enum-anon.swift +++ b/test/ClangImporter/enum-anon.swift @@ -1,22 +1,10 @@ // 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'}} } -