r237815 - [modules] Support merging a parsed default argument with an imported hidden one for non-type and template template parameters too.

Richard Smith richard-llvm at metafoo.co.uk
Wed May 20 11:24:22 PDT 2015


Author: rsmith
Date: Wed May 20 13:24:21 2015
New Revision: 237815

URL: http://llvm.org/viewvc/llvm-project?rev=237815&view=rev
Log:
[modules] Support merging a parsed default argument with an imported hidden one for non-type and template template parameters too.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=237815&r1=237814&r2=237815&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed May 20 13:24:21 2015
@@ -1358,6 +1358,8 @@ bool Sema::CheckTemplateParameterList(Te
       // Merge default arguments for non-type template parameters
       NonTypeTemplateParmDecl *OldNonTypeParm
         = OldParams? cast<NonTypeTemplateParmDecl>(*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(Te
       // Merge default arguments for template template parameters
       TemplateTemplateParmDecl *OldTemplateParm
         = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) : nullptr;
+      if (OldTemplateParm && !LookupResult::isVisible(*this, OldTemplateParm))
+        OldTemplateParm = nullptr;
       if (NewTemplateParm->isParameterPack()) {
         assert(!NewTemplateParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");

Modified: cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h?rev=237815&r1=237814&r2=237815&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h (original)
+++ cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h Wed May 20 13:24:21 2015
@@ -44,4 +44,5 @@ namespace G {
   typedef enum {} l;
 }
 
-template<typename T = int> int H(int a = 1);
+template<typename T = int, int N = 3, template<typename> class K = F> int H(int a = 1);
+template<typename T = int, int N = 3, template<typename> class K = F> using I = decltype(H<T, N, K>());





More information about the cfe-commits mailing list