[modules] Fix crash with multiple levels of default template argument merging.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 11 Jun 2015 23:46:11 +0000 (23:46 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 11 Jun 2015 23:46:11 +0000 (23:46 +0000)
llvm-svn: 239575

clang/include/clang/AST/DeclTemplate.h
clang/test/Modules/Inputs/submodules-merge-defs/defs.h
clang/test/Modules/submodules-merge-defs.cpp

index 26d1e99..0fc9b49 100644 (file)
@@ -265,7 +265,7 @@ public:
     const DefaultArgStorage *Storage = this;
     if (auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl*>())
       Storage = &Prev->getDefaultArgStorage();
-    if (auto *C = ValueOrInherited.template dyn_cast<Chain*>())
+    if (auto *C = Storage->ValueOrInherited.template dyn_cast<Chain*>())
       return C->Value;
     return Storage->ValueOrInherited.template get<ArgType>();
   }
index 1ab1d1a..4425946 100644 (file)
@@ -46,6 +46,7 @@ namespace G {
 
 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>());
+template<typename T = int, int N = 3, template<typename> class K = F> struct J {};
 
 namespace NS {
   struct A {};
index 6884f56..e7c0ad7 100644 (file)
@@ -40,6 +40,9 @@ int pre_ff = F<int>().f(); // expected-error +{{must be imported}}
 int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}}
 // expected-note@defs.h:26 +{{here}}
 
+J<> pre_j; // expected-error {{must be imported}} expected-error {{too few}}
+// expected-note@defs.h:49 +{{here}}
+
 // Make definitions from second module visible.
 #ifdef TEXTUAL
 #include "import-and-redefine.h"
@@ -65,3 +68,6 @@ int post_fg = F<char>().g<int>();
 // expected-error@-5 {{no matching member function}}
 // expected-note@defs.h:34 {{substitution failure}}
 #endif
+J<> post_j;
+template<typename T, int N, template<typename> class K> struct J;
+J<> post_j2;