From: Reid Kleckner Date: Fri, 19 Feb 2016 01:15:08 +0000 (+0000) Subject: [Sema] PR25181 Fix crash when method declaration with throw spec fails to parse correctly X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3cafc631338c4820bbfbddf38baa7f135752876;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261292 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 89ef35c88b..07e32b7e42 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -52,7 +52,8 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, } } - HandleMemberFunctionDeclDelays(D, FnD); + if (FnD) + HandleMemberFunctionDeclDelays(D, FnD); D.complete(FnD); diff --git a/test/SemaCXX/pr25181-crash-on-invalid.cpp b/test/SemaCXX/pr25181-crash-on-invalid.cpp new file mode 100644 index 0000000000..41178c95e8 --- /dev/null +++ b/test/SemaCXX/pr25181-crash-on-invalid.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// Don't crash (PR25181). + +template class Foo { // expected-note {{template parameter is declared here}} + template // expected-error {{declaration of 'T' shadows template parameter}} + void Foo::method(T *) const throw() {} // expected-error {{nested name specifier 'Foo::' for declaration does not refer into a class, class template or class template partial specialization}} +};