[modules] Fix crash with multiple levels of default template argument merging.

llvm-svn: 239575
This commit is contained in:
Richard Smith 2015-06-11 23:46:11 +00:00
parent 81d1cc00b7
commit c785276b92
3 changed files with 8 additions and 1 deletions

View 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>();
}

View 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 {};

View 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;