Skip to content

Commit 7c9bd16

Browse files
authored
Merge pull request swiftlang#83813 from egorzhdan/egorzhdan/partial-spec-var
[cxx-interop] Do not import partial specializations of variables
2 parents 303c1ee + 7797552 commit 7c9bd16

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
@@ -4697,6 +4697,11 @@ namespace {
46974697
return result;
46984698
}
46994699

4700+
Decl *VisitVarTemplatePartialSpecializationDecl(
4701+
const clang::VarTemplatePartialSpecializationDecl *decl) {
4702+
return nullptr;
4703+
}
4704+
47004705
Decl *VisitImplicitParamDecl(const clang::ImplicitParamDecl *decl) {
47014706
// Parameters are never directly imported.
47024707
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)