summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-04 11:57:16 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-04 11:57:16 +0000
commit0fcaac9ef33996215842da516e50525071ccb68a (patch)
treee82121d2024aac5d5028293d6beb053b8aef2f89 /clang/lib/Parse/Parser.cpp
parent05edf944c0f3c057247c50bd1e57ff8613ab0a3a (diff)
downloadbcm5719-llvm-0fcaac9ef33996215842da516e50525071ccb68a.tar.gz
bcm5719-llvm-0fcaac9ef33996215842da516e50525071ccb68a.zip
Fix a crash-on-invalid where we were trying to parse C++ constructs in
C, then hitting an assertion because C code shouldn't try to parse optional nested-name-specifiers. Fixes PR9137. llvm-svn: 124860
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r--clang/lib/Parse/Parser.cpp5
1 files changed, 3 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 '{'.
OpenPOWER on IntegriCloud