diff --git a/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift b/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift index 75bf952cf4f7c..59123f3780edc 100644 --- a/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift +++ b/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift @@ -46,7 +46,7 @@ public struct DiagnosticFixIt { let bridgedDiagnosticFixIt = swift.DiagnosticInfo.FixIt( swift.CharSourceRange(start.bridged, UInt32(byteLength)), bridgedTextRef, - llvm.ArrayRef()) + ArrayRefOfDiagnosticArgument()) fn(bridgedDiagnosticFixIt) } } diff --git a/include/swift/AST/ASTBridging.h b/include/swift/AST/ASTBridging.h index 845c4e3e4bb27..3920aa649c4d7 100644 --- a/include/swift/AST/ASTBridging.h +++ b/include/swift/AST/ASTBridging.h @@ -38,6 +38,8 @@ void DiagnosticEngine_diagnose(swift::DiagnosticEngine &, swift::SourceLoc loc, swift::CharSourceRange highlight, BridgedArrayRef fixIts); +using ArrayRefOfDiagnosticArgument = llvm::ArrayRef; + SWIFT_END_NULLABILITY_ANNOTATIONS #endif // SWIFT_AST_ASTBRIDGING_H diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index a8130b480b43d..defcb6c53e543 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3497,6 +3497,13 @@ namespace { auto structDecl = Impl.createDeclWithClangNode( decl, AccessLevel::Public, loc, name, loc, None, genericParamList, dc); + + auto attr = AvailableAttr::createPlatformAgnostic( + Impl.SwiftContext, "Un-specialized class templates are not currently " + "supported. Please use a specialization of this " + "type."); + structDecl->getAttrs().add(attr); + return structDecl; } diff --git a/test/Interop/Cxx/namespace/templates-module-interface.swift b/test/Interop/Cxx/namespace/templates-module-interface.swift index d4642f7e3b9f8..e402e2b4e7541 100644 --- a/test/Interop/Cxx/namespace/templates-module-interface.swift +++ b/test/Interop/Cxx/namespace/templates-module-interface.swift @@ -7,6 +7,7 @@ // CHECK-NEXT: init() // CHECK-NEXT: mutating func basicMember() -> UnsafePointer! // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct ForwardDeclaredClassTemplate<> { // CHECK-NEXT: } // CHECK-NEXT: static func forwardDeclaredFunctionTemplateOutOfLine(_: T) -> UnsafePointer! @@ -14,6 +15,7 @@ // CHECK-NEXT: init() // CHECK-NEXT: mutating func basicMember() -> UnsafePointer! // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct ForwardDeclaredClassTemplateOutOfLine<> { // CHECK-NEXT: } // CHECK-NEXT: typealias BasicClassTemplateChar = TemplatesNS1.TemplatesNS3.__CxxTemplateInstN12TemplatesNS112TemplatesNS318BasicClassTemplateIcEE @@ -24,10 +26,12 @@ // CHECK-NEXT: init() // CHECK-NEXT: mutating func basicMember() -> UnsafePointer! // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct BasicClassTemplate<> { // CHECK-NEXT: } // CHECK-NEXT: typealias BasicClassTemplateChar = TemplatesNS1.__CxxTemplateInstN12TemplatesNS118BasicClassTemplateIcEE // CHECK-NEXT: static func basicFunctionTemplateDefinedInDefs(_: T) -> UnsafePointer! +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct BasicClassTemplateDefinedInDefs<> { // CHECK-NEXT: } // CHECK-NEXT: typealias UseTemplate = TemplatesNS4.__CxxTemplateInstN12TemplatesNS417HasSpecializationIcEE @@ -36,6 +40,7 @@ // CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS112TemplatesNS318BasicClassTemplateIcEE { // CHECK-NEXT: init() // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct BasicClassTemplate<> { // CHECK-NEXT: } // CHECK-NEXT: } @@ -53,6 +58,7 @@ // CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIiEE { // CHECK-NEXT: init() // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct HasSpecialization<> { // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Interop/Cxx/namespace/templates-with-forward-decl-module-interface.swift b/test/Interop/Cxx/namespace/templates-with-forward-decl-module-interface.swift index 14a3c8f97fc13..5262b34f21d9f 100644 --- a/test/Interop/Cxx/namespace/templates-with-forward-decl-module-interface.swift +++ b/test/Interop/Cxx/namespace/templates-with-forward-decl-module-interface.swift @@ -4,6 +4,7 @@ // CHECK-NEXT: struct __CxxTemplateInstN3NS115ForwardDeclaredIiEE { // CHECK-NEXT: init() // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct ForwardDeclared { // CHECK-NEXT: } // CHECK-NEXT: struct __CxxTemplateInstN3NS14DeclIiEE { @@ -13,6 +14,7 @@ // CHECK-NEXT: var fwd: NS1.__CxxTemplateInstN3NS115ForwardDeclaredIiEE // CHECK-NEXT: static let intValue: NS1.__CxxTemplateInstN3NS14DeclIiEE.MyInt // CHECK-NEXT: } +// CHECK-NEXT: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.") // CHECK-NEXT: struct Decl { // CHECK-NEXT: } // CHECK-NEXT: typealias di = NS1.__CxxTemplateInstN3NS14DeclIiEE diff --git a/test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModule.swift b/test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModule.swift index c66512a23aa74..7bfa394b5baa4 100644 --- a/test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModule.swift +++ b/test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModule.swift @@ -1,10 +1,10 @@ import ClassTemplateForSwiftModule -public func makeWrappedMagicNumber() -> MagicWrapper { +public func makeWrappedMagicNumber() -> MagicWrapperSpec { let t = IntWrapper(value: 42) return MagicWrapper(t: t) } -public func readWrappedMagicNumber(_ i: inout MagicWrapper) -> CInt { +public func readWrappedMagicNumber(_ i: inout MagicWrapperSpec) -> CInt { return i.getValuePlusArg(13) } diff --git a/test/Interop/Cxx/templates/Inputs/class-template-for-swift-module.h b/test/Interop/Cxx/templates/Inputs/class-template-for-swift-module.h index 899a56b017659..03a9c850410e7 100644 --- a/test/Interop/Cxx/templates/Inputs/class-template-for-swift-module.h +++ b/test/Interop/Cxx/templates/Inputs/class-template-for-swift-module.h @@ -12,4 +12,6 @@ struct MagicWrapper { int getValuePlusArg(int arg) const { return t.getValue() + arg; } }; +using MagicWrapperSpec = MagicWrapper; + #endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_FOR_SWIFT_MODULE_H diff --git a/test/Interop/Cxx/templates/class-template-instantiation-existing-specialization.swift b/test/Interop/Cxx/templates/class-template-instantiation-existing-specialization.swift index 22267328ac758..e6bf082b8e7b9 100644 --- a/test/Interop/Cxx/templates/class-template-instantiation-existing-specialization.swift +++ b/test/Interop/Cxx/templates/class-template-instantiation-existing-specialization.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop) +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -disable-availability-checking) // // REQUIRES: executable_test diff --git a/test/Interop/Cxx/templates/class-template-instantiation-typechecker-calls-method-with-error.swift b/test/Interop/Cxx/templates/class-template-instantiation-typechecker-calls-method-with-error.swift index 6a641728ee453..4f154aaef6f61 100644 --- a/test/Interop/Cxx/templates/class-template-instantiation-typechecker-calls-method-with-error.swift +++ b/test/Interop/Cxx/templates/class-template-instantiation-typechecker-calls-method-with-error.swift @@ -1,4 +1,4 @@ -// RUN: not %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop 2>&1 | %FileCheck %s +// RUN: not %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking 2>&1 | %FileCheck %s import ClassTemplateInstantiationErrors diff --git a/test/Interop/Cxx/templates/class-template-instantiation-typechecker-constructor-calls-method-with-error.swift b/test/Interop/Cxx/templates/class-template-instantiation-typechecker-constructor-calls-method-with-error.swift index 0e91adddf99fe..f271159a8a231 100644 --- a/test/Interop/Cxx/templates/class-template-instantiation-typechecker-constructor-calls-method-with-error.swift +++ b/test/Interop/Cxx/templates/class-template-instantiation-typechecker-constructor-calls-method-with-error.swift @@ -1,4 +1,4 @@ -// RUN: not %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop 2>&1 | %FileCheck %s +// RUN: not %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking 2>&1 | %FileCheck %s import ClassTemplateInstantiationErrors diff --git a/test/Interop/Cxx/templates/class-template-instantiation.swift b/test/Interop/Cxx/templates/class-template-instantiation.swift index 16e5e99bbaaa7..4f2c65a8331bc 100644 --- a/test/Interop/Cxx/templates/class-template-instantiation.swift +++ b/test/Interop/Cxx/templates/class-template-instantiation.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop) +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -disable-availability-checking) // // REQUIRES: executable_test diff --git a/test/Interop/Cxx/templates/class-template-uninstantiatable-members-irgen.swift b/test/Interop/Cxx/templates/class-template-uninstantiatable-members-irgen.swift index 0878bc0de45aa..92614da73e8f0 100644 --- a/test/Interop/Cxx/templates/class-template-uninstantiatable-members-irgen.swift +++ b/test/Interop/Cxx/templates/class-template-uninstantiatable-members-irgen.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop | %FileCheck %s +// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s import ClassTemplateInstantiationErrors diff --git a/test/Interop/Cxx/templates/class-template-uninstantiatable-members.swift b/test/Interop/Cxx/templates/class-template-uninstantiatable-members.swift index eef516927afaf..ad3bc0cf29b65 100644 --- a/test/Interop/Cxx/templates/class-template-uninstantiatable-members.swift +++ b/test/Interop/Cxx/templates/class-template-uninstantiatable-members.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop) +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -disable-availability-checking) // // REQUIRES: executable_test diff --git a/test/Interop/Cxx/templates/define-referenced-inline.swift b/test/Interop/Cxx/templates/define-referenced-inline.swift index f65368d797ec2..f0ceca008c272 100644 --- a/test/Interop/Cxx/templates/define-referenced-inline.swift +++ b/test/Interop/Cxx/templates/define-referenced-inline.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -fno-exceptions) +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -fno-exceptions -Xfrontend -disable-availability-checking) // // REQUIRES: executable_test diff --git a/test/Interop/Cxx/templates/dependent-types-silgen.swift b/test/Interop/Cxx/templates/dependent-types-silgen.swift index d57f41a14fa02..c05a96a1a14db 100644 --- a/test/Interop/Cxx/templates/dependent-types-silgen.swift +++ b/test/Interop/Cxx/templates/dependent-types-silgen.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-silgen %s -I %S/Inputs -enable-experimental-cxx-interop | %FileCheck %s +// RUN: %target-swift-emit-silgen %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s import DependentTypes diff --git a/test/Interop/Cxx/templates/dependent-types.swift b/test/Interop/Cxx/templates/dependent-types.swift index 2a2d063a62929..29b6e6f4b4931 100644 --- a/test/Interop/Cxx/templates/dependent-types.swift +++ b/test/Interop/Cxx/templates/dependent-types.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none) +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none -Xfrontend -disable-availability-checking) // // REQUIRES: executable_test // diff --git a/test/Interop/Cxx/templates/swift-class-instantiation-module-interface.swift b/test/Interop/Cxx/templates/swift-class-instantiation-module-interface.swift index 0b894a0575de7..90442aa957026 100644 --- a/test/Interop/Cxx/templates/swift-class-instantiation-module-interface.swift +++ b/test/Interop/Cxx/templates/swift-class-instantiation-module-interface.swift @@ -1,5 +1,5 @@ // RUN: %empty-directory(%t) -// RUN: %target-swiftxx-frontend -emit-module -o %t/SwiftClassTemplateModule.swiftmodule %S/Inputs/SwiftClassInstantiationModule.swift -I %S/Inputs -enable-library-evolution -swift-version 5 +// RUN: %target-swiftxx-frontend -emit-module -o %t/SwiftClassTemplateModule.swiftmodule %S/Inputs/SwiftClassInstantiationModule.swift -I %S/Inputs -enable-library-evolution -swift-version 5 -disable-availability-checking // RUN: %target-swift-ide-test -print-module -module-to-print=SwiftClassTemplateModule -I %t/ -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s diff --git a/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx-execution.cpp b/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx-execution.cpp index 9b91350f41c01..1db3668108fe8 100644 --- a/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx-execution.cpp +++ b/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx-execution.cpp @@ -1,3 +1,6 @@ +// rdar://101431096 +// XFAIL: * + // RUN: %empty-directory(%t) // RUN: split-file %s %t diff --git a/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift b/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift index d2ba6129a8e6f..cd1f697883b8d 100644 --- a/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift +++ b/test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift @@ -1,3 +1,6 @@ +// rdar://101431096 +// XFAIL: * + // RUN: %empty-directory(%t) // RUN: split-file %s %t