diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Parse/Parser.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Parser/cxx-in-c.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 3327f7b5a90..4b2bd0d89cf 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -739,8 +739,9 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, // We should have either an opening brace or, in a C++ constructor, // we may have a colon. - if (Tok.isNot(tok::l_brace) && Tok.isNot(tok::colon) && - Tok.isNot(tok::kw_try)) { + if (Tok.isNot(tok::l_brace) && + (!getLang().CPlusPlus || + (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 '{'. diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c new file mode 100644 index 00000000000..50212ad0b31 --- /dev/null +++ b/clang/test/Parser/cxx-in-c.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify + +// PR9137 +void f0(int x) : {}; +void f1(int x) try {}; |

