]> granicus.if.org Git - clang/commit
[Sema] Fix a multiple definition bug with friends and templates
authorErik Pilkington <erik.pilkington@gmail.com>
Wed, 10 Oct 2018 17:17:51 +0000 (17:17 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Wed, 10 Oct 2018 17:17:51 +0000 (17:17 +0000)
commitc72f348e95ced873b69abde93040060a12a1a3a6
tree03ae4eb8fe0bde3870e44cad2c4bd35a270cc965
parent27fe8790f1e12d29a15188192f52f2ac3e4fd672
[Sema] Fix a multiple definition bug with friends and templates

The problem was that MergeFunctionDecl sometimes needs the injected template
arguments of a FunctionTemplateDecl, but is called before adding the new
template to the redecl chain. This leads to multiple common pointers in the same
redecl chain, each with their own identical instantiation. Fix this by merging
the the common state before inserting the new template into the redecl chain.

rdar://44810129

Differential revision: https://reviews.llvm.org/D53046

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344157 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/DeclTemplate.h
lib/AST/DeclTemplate.cpp
lib/Sema/SemaDecl.cpp
test/SemaCXX/friend-template-redecl.cpp [new file with mode: 0644]