diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-04-26 20:35:05 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-04-26 20:35:05 +0000 |
commit | d3a413d3b8eb39bcee5944bc545d9997c1abe492 (patch) | |
tree | 9c84c3e5e12e5fd96b0aee7dd662e61e6d230359 /lib/Parse/Parser.cpp | |
parent | 9a901bb63990574ff0bcc12ff851d7a71cff8ddb (diff) |
Implement function-try-blocks. However, there's a very subtle bug that I can't track down.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index a245ac2156..94036dbd86 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -536,7 +536,8 @@ Parser::ParseDeclarationOrFunctionDefinition( (!getLang().CPlusPlus && isDeclarationSpecifier()) || // int X(f) int f; {} (getLang().CPlusPlus && - Tok.is(tok::colon)))) { // X() : Base() {} (used for ctors) + (Tok.is(tok::colon) || // X() : Base() {} (used for ctors) + Tok.is(tok::kw_try))))) { // X() try { ... } if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { Diag(Tok, diag::err_function_declared_typedef); @@ -575,7 +576,7 @@ Parser::ParseDeclarationOrFunctionDefinition( /// decl-specifier-seq[opt] declarator ctor-initializer[opt] /// function-body /// [C++] function-definition: [C++ 8.4] -/// decl-specifier-seq[opt] declarator function-try-block [TODO] +/// decl-specifier-seq[opt] declarator function-try-block /// Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D) { const DeclaratorChunk &FnTypeInfo = D.getTypeObject(0); @@ -602,8 +603,8 @@ Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D) { // We should have either an opening brace or, in a C++ constructor, // we may have a colon. - // FIXME: In C++, we might also find the 'try' keyword. - if (Tok.isNot(tok::l_brace) && Tok.isNot(tok::colon)) { + if (Tok.isNot(tok::l_brace) && Tok.isNot(tok::colon) && + Tok.isNot(tok::kw_try)) { Diag(Tok, diag::err_expected_fn_body); // Skip over garbage, until we get to '{'. Don't eat the '{'. @@ -621,12 +622,14 @@ Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D) { // specified Declarator for the function. DeclPtrTy Res = Actions.ActOnStartOfFunctionDef(CurScope, D); + if (Tok.is(tok::kw_try)) + return ParseFunctionTryBlock(Res); + // If we have a colon, then we're probably parsing a C++ // ctor-initializer. if (Tok.is(tok::colon)) ParseConstructorInitializer(Res); - SourceLocation BraceLoc = Tok.getLocation(); return ParseFunctionStatementBody(Res); } |