[Sema] PR25181 Fix crash when method declaration with throw spec fails to parse correctly

Fixes crash referenced in PR25181 where dyn_cast is called on a null
instance of LM.Method.

Reviewers: majnemer, rnk

Patch by Don Hinton

Differential Revision: http://reviews.llvm.org/D17072

llvm-svn: 261292
This commit is contained in:
Reid Kleckner 2016-02-19 01:15:08 +00:00
parent eafc693c90
commit bde5ede526
2 changed files with 9 additions and 1 deletions

View File

@ -52,7 +52,8 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS,
}
}
HandleMemberFunctionDeclDelays(D, FnD);
if (FnD)
HandleMemberFunctionDeclDelays(D, FnD);
D.complete(FnD);

View File

@ -0,0 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// Don't crash (PR25181).
template <typename T> class Foo { // expected-note {{template parameter is declared here}}
template <typename T> // expected-error {{declaration of 'T' shadows template parameter}}
void Foo<T>::method(T *) const throw() {} // expected-error {{nested name specifier 'Foo<T>::' for declaration does not refer into a class, class template or class template partial specialization}}
};