Skip to content

Commit

Permalink
[Sema] PR25181 Fix crash when method declaration with throw spec fail…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
rnk committed Feb 19, 2016
1 parent eafc693 commit bde5ede
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Parse/ParseCXXInlineMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS,
}
}

HandleMemberFunctionDeclDelays(D, FnD);
if (FnD)
HandleMemberFunctionDeclDelays(D, FnD);

D.complete(FnD);

Expand Down
7 changes: 7 additions & 0 deletions clang/test/SemaCXX/pr25181-crash-on-invalid.cpp
Original file line number Diff line number Diff line change
@@ -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}}
};

0 comments on commit bde5ede

Please sign in to comment.