From: Richard Smith Date: Wed, 20 May 2015 18:24:21 +0000 (+0000) Subject: [modules] Support merging a parsed default argument with an imported hidden one for... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da3e223c1b5f85b0f0d723a2d3d66d650fb4ad9f;p=clang [modules] Support merging a parsed default argument with an imported hidden one for non-type and template template parameters too. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237815 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 9546d38fc3..b5d04cf1a1 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1358,6 +1358,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // Merge default arguments for non-type template parameters NonTypeTemplateParmDecl *OldNonTypeParm = OldParams? cast(*OldParam) : nullptr; + if (OldNonTypeParm && !LookupResult::isVisible(*this, OldNonTypeParm)) + OldNonTypeParm = nullptr; if (NewNonTypeParm->isParameterPack()) { assert(!NewNonTypeParm->hasDefaultArgument() && "Parameter packs can't have a default argument!"); @@ -1405,6 +1407,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // Merge default arguments for template template parameters TemplateTemplateParmDecl *OldTemplateParm = OldParams? cast(*OldParam) : nullptr; + if (OldTemplateParm && !LookupResult::isVisible(*this, OldTemplateParm)) + OldTemplateParm = nullptr; if (NewTemplateParm->isParameterPack()) { assert(!NewTemplateParm->hasDefaultArgument() && "Parameter packs can't have a default argument!"); diff --git a/test/Modules/Inputs/submodules-merge-defs/defs.h b/test/Modules/Inputs/submodules-merge-defs/defs.h index 2ec56027ad..68b57a4a62 100644 --- a/test/Modules/Inputs/submodules-merge-defs/defs.h +++ b/test/Modules/Inputs/submodules-merge-defs/defs.h @@ -44,4 +44,5 @@ namespace G { typedef enum {} l; } -template int H(int a = 1); +template class K = F> int H(int a = 1); +template class K = F> using I = decltype(H());