Skip to content

Commit 7797552

Browse files
committed
[cxx-interop] Do not import partial specializations of variables
They do not get imported correctly and trigger linker errors. rdar://149232900 / resolves swiftlang#80802
1 parent d8edd86 commit 7797552

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,6 +4638,11 @@ namespace {
46384638
return result;
46394639
}
46404640

4641+
Decl *VisitVarTemplatePartialSpecializationDecl(
4642+
const clang::VarTemplatePartialSpecializationDecl *decl) {
4643+
return nullptr;
4644+
}
4645+
46414646
Decl *VisitImplicitParamDecl(const clang::ImplicitParamDecl *decl) {
46424647
// Parameters are never directly imported.
46434648
return nullptr;

test/ClangImporter/const_values_cxx.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ func foo() {
5555

5656
print(MyClass().class_const_int)
5757
print(MyClass.class_static_const_int)
58-
59-
// TODO: This seems to be incorrectly imported, this test here is just to check that the compiler doesn't crash.
60-
print(template_gcd)
6158
}
6259

6360
// Only imported as external declarations:

test/Interop/Cxx/templates/Inputs/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,8 @@ module UninstantiatableSpecialMembers {
177177
header "uninstantiatable-special-members.h"
178178
requires cplusplus
179179
}
180+
181+
module VariableTemplate {
182+
header "variable-template.h"
183+
requires cplusplus
184+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
template <int N, int M>
2+
inline const int template_gcd = template_gcd<M, N % M>;
3+
4+
template <int N>
5+
inline const int template_gcd<N, 0> = N;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift -cxx-interoperability-mode=default -I %S/Inputs
2+
3+
import VariableTemplate
4+
5+
let _: CInt = template_gcd // expected-error {{cannot find 'template_gcd' in scope}}

0 commit comments

Comments
 (0)