From fcb490da02cd1fe8cf91b71fc76d84e2cc8a6f19 Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Fri, 21 Oct 2022 21:39:43 -0700 Subject: [PATCH] Test: Enhance TBDGen test coverage for the `@_specialize` attribute. --- test/TBD/specialize_attr.swift | 51 ++++++++++++++++++++++++++++++++ test/TBD/specialize_verify.swift | 7 ----- 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 test/TBD/specialize_attr.swift delete mode 100644 test/TBD/specialize_verify.swift diff --git a/test/TBD/specialize_attr.swift b/test/TBD/specialize_attr.swift new file mode 100644 index 0000000000000..2007fcedaf7ac --- /dev/null +++ b/test/TBD/specialize_attr.swift @@ -0,0 +1,51 @@ +// REQUIRES: VENDOR=apple + +// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s +// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s +// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing +// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing + +// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing -O %s +// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing -O %s +// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O +// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O + +@_specialize(exported: false, where T == Int) +@_specialize(exported: true, where T == Float) +public func foo(_ x : T) -> T { return x } + +@_specialize(exported: false, where T == Int) +@_specialize(exported: true, where T == Float) +internal func fooInternal(_ x : T) -> T { return x } + +@_specialize(exported: false, where T == Int) +@_specialize(exported: true, where T == Float) +private func fooPrivate(_ x : T) -> T { return x } + +public struct S { + @_specialize(exported: false, where T == Int) + @_specialize(exported: true, where T == Float) + public func foo(_ x : T) -> T { return x } + + @_specialize(exported: false, where T == Int) + @_specialize(exported: true, where T == Float) + internal func fooInternal(_ x : T) -> T { return x } + + @_specialize(exported: false, where T == Int) + @_specialize(exported: true, where T == Float) + private func fooPrivate(_ x : T) -> T { return x } +} + +public class C { + @_specialize(exported: false, where T == Int) + @_specialize(exported: true, where T == Float) + public func foo(_ x : T) -> T { return x } + + @_specialize(exported: false, where T == Int) + @_specialize(exported: true, where T == Float) + internal func fooInternal(_ x : T) -> T { return x } + + @_specialize(exported: false, where T == Int) + @_specialize(exported: true, where T == Float) + private func fooPrivate(_ x : T) -> T { return x } +} diff --git a/test/TBD/specialize_verify.swift b/test/TBD/specialize_verify.swift deleted file mode 100644 index e7942965a5c73..0000000000000 --- a/test/TBD/specialize_verify.swift +++ /dev/null @@ -1,7 +0,0 @@ -// REQUIRES: VENDOR=apple -// RUN: %target-swift-frontend -emit-ir -o/dev/null -O -module-name test -validate-tbd-against-ir=missing %s - -@_specialize(exported: true, where T == Float) -public func foo(_ x : T) -> T { - return x -}