]> granicus.if.org Git - clang/commitdiff
[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)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239575 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 26d1e99a05b5885d8adb2ff394a44252f5b02fa5..0fc9b4947d491071c808d8b1474eb1e6d0c64ff9 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 1ab1d1a005be3b961a20db84994c61fb25251bc9..44259463a10280785f2cc845493941eb2593fbe1 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 6884f56ce7d9a2375fd1aa65d3133780bd3abe5e..e7c0ad7f0c1cbda7d5579ad8cd6e64cfed8a1d97 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;