From: Argyrios Kyrtzidis Date: Wed, 5 Jun 2013 17:52:24 +0000 (+0000) Subject: When the template specialization header is missing, set a valid source location for... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d62d9015c76d4e7dee1fddd9603b92098b355e15;p=clang When the template specialization header is missing, set a valid source location for the template keyword when recovering. Otherwise ClassTemplateSpecializationDecl::getSourceRange() will mistakenly consider itself as an implicit partial specialization and lead to a crash. Fixes rdar://14063074 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183325 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index ad866a347e..8621a2d42d 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -5300,6 +5300,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, } else if (TUK != TUK_Friend) { Diag(KWLoc, diag::err_template_spec_needs_header) << FixItHint::CreateInsertion(KWLoc, "template<> "); + TemplateKWLoc = KWLoc; isExplicitSpecialization = true; } diff --git a/test/Index/index-file.cpp b/test/Index/index-file.cpp index 7634c0db86..37b14a2715 100644 --- a/test/Index/index-file.cpp +++ b/test/Index/index-file.cpp @@ -4,7 +4,20 @@ extern "C" { template < typename T > *Allocate() { } } +// rdar://14063074 +namespace rdar14063074 { +template +struct TS {}; +struct TS {}; + +template +void tfoo() {} +void tfoo() {} +} + // RUN: c-index-test -index-file %s > %t // RUN: FileCheck %s -input-file=%t // CHECK: [indexDeclaration]: kind: type-alias | name: MyTypeAlias | {{.*}} | loc: 1:7 +// CHECK: [indexDeclaration]: kind: struct-template-spec | name: TS | {{.*}} | loc: 11:8 +// CHECK: [indexDeclaration]: kind: function-template-spec | name: tfoo | {{.*}} | loc: 15:6