[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 9 15:09:09 PDT 2018
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall.
Herald added a subscriber: dexonsmith.
Clang used to error out on the attached testcase, due to multiple definitions of `foo<int>`. The problem is that multiple FunctionTemplateDecl::Common pointers are created for the two FunctionTemplateDeclarations `foo` in the redeclaration chain, each with their own copy of the instantiation of `f<int>`.
This patch fixes the problem by using the previous function template in a call to `FuntionTemplateDecl::getInjectedTemplateArgs()` (this was the call that caused the Common pointer to be allocated in the redeclaration). Most of this patch is just boilerplate to get the function template declaration down the stack to where it's needed.
Fixes rdar://44810129
Thanks for taking a look!
Erik
Repository:
rC Clang
https://reviews.llvm.org/D53046
Files:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/friend-template-redecl.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53046.168876.patch
Type: text/x-patch
Size: 8841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181009/a2916c9a/attachment-0001.bin>
More information about the cfe-commits
mailing list