[cxx-interop] Do not import partial specializations of variables

They do not get imported correctly and trigger linker errors.

rdar://149232900 / resolves https://github.com/swiftlang/swift/issues/80802
This commit is contained in:
Egor Zhdan
2025-08-19 17:24:04 +01:00
parent d8edd86cfb
commit 77975524be
5 changed files with 20 additions and 3 deletions

View File

@@ -4638,6 +4638,11 @@ namespace {
return result;
}
Decl *VisitVarTemplatePartialSpecializationDecl(
const clang::VarTemplatePartialSpecializationDecl *decl) {
return nullptr;
}
Decl *VisitImplicitParamDecl(const clang::ImplicitParamDecl *decl) {
// Parameters are never directly imported.
return nullptr;

View File

@@ -55,9 +55,6 @@ func foo() {
print(MyClass().class_const_int)
print(MyClass.class_static_const_int)
// TODO: This seems to be incorrectly imported, this test here is just to check that the compiler doesn't crash.
print(template_gcd)
}
// Only imported as external declarations:

View File

@@ -177,3 +177,8 @@ module UninstantiatableSpecialMembers {
header "uninstantiatable-special-members.h"
requires cplusplus
}
module VariableTemplate {
header "variable-template.h"
requires cplusplus
}

View File

@@ -0,0 +1,5 @@
template <int N, int M>
inline const int template_gcd = template_gcd<M, N % M>;
template <int N>
inline const int template_gcd<N, 0> = N;

View File

@@ -0,0 +1,5 @@
// RUN: %target-typecheck-verify-swift -cxx-interoperability-mode=default -I %S/Inputs
import VariableTemplate
let _: CInt = template_gcd // expected-error {{cannot find 'template_gcd' in scope}}