]> granicus.if.org Git - clang/commit
[Sema] Fix assertion when constructor is disabled with partially specialized template.
authorVolodymyr Sapsai <vsapsai@apple.com>
Wed, 16 May 2018 18:28:58 +0000 (18:28 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Wed, 16 May 2018 18:28:58 +0000 (18:28 +0000)
commit2bf461475f540aee10dedff531f66851d765fcda
tree112cf975dcb5f3084c636fc6b884d6a59cff01f2
parent1b1c8e45f05abd93d06d93659a0c372400e2b76d
[Sema] Fix assertion when constructor is disabled with partially specialized template.

The added test case was triggering assertion

> Assertion failed: (!SpecializedTemplate.is<SpecializedPartialSpecialization*>() && "Already set to a class template partial specialization!"), function setInstantiationOf, file clang/include/clang/AST/DeclTemplate.h, line 1825.

It was happening with ClassTemplateSpecializationDecl
`enable_if_not_same<int, int>`. Because this template is specialized for
equal types not to have a definition, it wasn't instantiated and its
specialization kind remained TSK_Undeclared. And because it was implicit
instantiation, we didn't mark the decl as invalid. So when we try to
find the best matching partial specialization the second time, we hit
the assertion as partial specialization is already set.

Fix by reusing stored partial specialization when available, instead of
looking for the best match every time.

rdar://problem/39524996

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D46909

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332509 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaTemplateInstantiate.cpp
test/SemaTemplate/partial-spec-instantiate.cpp