From 1c7047375a180ff80abb414e2075b1d5a240bb77 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 10 Nov 2011 09:08:44 +0000 Subject: [PATCH] PR11148: Fix crash-on-invalid if an invalid member declaration is marked as defaulted or deleted. llvm-svn: 144270 --- clang/lib/Parse/ParseCXXInlineMethods.cpp | 5 +++++ clang/test/Parser/cxx-default-delete.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index 65f7f56fe93d..2877628f262f 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -66,6 +66,11 @@ Decl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, if (Tok.is(tok::equal)) { ConsumeToken(); + if (!FnD) { + SkipUntil(tok::semi); + return 0; + } + bool Delete = false; SourceLocation KWLoc; if (Tok.is(tok::kw_delete)) { diff --git a/clang/test/Parser/cxx-default-delete.cpp b/clang/test/Parser/cxx-default-delete.cpp index f34f6fb014f2..9ace0acee89b 100644 --- a/clang/test/Parser/cxx-default-delete.cpp +++ b/clang/test/Parser/cxx-default-delete.cpp @@ -13,3 +13,7 @@ struct foo { }; void baz() = delete; + +struct quux { + int quux() = default; // expected-error{{constructor cannot have a return type}} expected-error {{member 'quux' has the same name as its class}} +};