[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 15 15:32:00 PDT 2018


vsapsai created this revision.
vsapsai added reviewers: rsmith, arphaman.

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


https://reviews.llvm.org/D46909

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/partial-spec-instantiate.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46909.146943.patch
Type: text/x-patch
Size: 13478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180515/5e296aad/attachment.bin>


More information about the cfe-commits mailing list