aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-07 10:31:35 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-07 10:31:35 +0000
commit63644fae3970d4146200e4cb25dd9aace34a3398 (patch)
tree0ff61d14c26ffb1eba29ec6542c5a9c5027e894e /lib/Sema/SemaTemplateInstantiateDecl.cpp
parent63a011378d4b9483ce24400c163cb8d65ea096a5 (diff)
Workaround for friend template instantiation crash in PR5848, from Keir Mierle!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95517 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 244b5f511b..d7820bbc2e 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -411,9 +411,17 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) {
Decl *NewND;
// Hack to make this work almost well pending a rewrite.
- if (ND->getDeclContext()->isRecord())
- NewND = SemaRef.FindInstantiatedDecl(ND, TemplateArgs);
- else if (D->wasSpecialization()) {
+ if (ND->getDeclContext()->isRecord()) {
+ if (!ND->getDeclContext()->isDependentContext()) {
+ NewND = SemaRef.FindInstantiatedDecl(ND, TemplateArgs);
+ } else {
+ // FIXME: Hack to avoid crashing when incorrectly trying to instantiate
+ // templated friend declarations. This doesn't produce a correct AST;
+ // however this is sufficient for some AST analysis. The real solution
+ // must be put in place during the pending rewrite. See PR5848.
+ return 0;
+ }
+ } else if (D->wasSpecialization()) {
// Totally egregious hack to work around PR5866
return 0;
} else