From: Richard Smith Date: Thu, 11 Jun 2015 23:46:11 +0000 (+0000) Subject: [modules] Fix crash with multiple levels of default template argument merging. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c785276b926f57d6c606cebc1392facc61d18529;p=platform%2Fupstream%2Fllvm.git [modules] Fix crash with multiple levels of default template argument merging. llvm-svn: 239575 --- diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 26d1e99..0fc9b49 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -265,7 +265,7 @@ public: const DefaultArgStorage *Storage = this; if (auto *Prev = ValueOrInherited.template dyn_cast()) Storage = &Prev->getDefaultArgStorage(); - if (auto *C = ValueOrInherited.template dyn_cast()) + if (auto *C = Storage->ValueOrInherited.template dyn_cast()) return C->Value; return Storage->ValueOrInherited.template get(); } diff --git a/clang/test/Modules/Inputs/submodules-merge-defs/defs.h b/clang/test/Modules/Inputs/submodules-merge-defs/defs.h index 1ab1d1a..4425946 100644 --- a/clang/test/Modules/Inputs/submodules-merge-defs/defs.h +++ b/clang/test/Modules/Inputs/submodules-merge-defs/defs.h @@ -46,6 +46,7 @@ namespace G { template class K = F> int H(int a = 1); template class K = F> using I = decltype(H()); +template class K = F> struct J {}; namespace NS { struct A {}; diff --git a/clang/test/Modules/submodules-merge-defs.cpp b/clang/test/Modules/submodules-merge-defs.cpp index 6884f56..e7c0ad7 100644 --- a/clang/test/Modules/submodules-merge-defs.cpp +++ b/clang/test/Modules/submodules-merge-defs.cpp @@ -40,6 +40,9 @@ int pre_ff = F().f(); // expected-error +{{must be imported}} int pre_fg = F().g(); // 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().g(); // expected-error@-5 {{no matching member function}} // expected-note@defs.h:34 {{substitution failure}} #endif +J<> post_j; +template class K> struct J; +J<> post_j2;