summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-10-15 01:34:54 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-10-15 01:34:54 +0000
commitc2c8bb82096bc938d776557c037cb874de695f80 (patch)
tree8a958628fb0c1a83e8718f411898b66649f52bc0 /clang/lib/Parse/ParseStmt.cpp
parentec67c90216220daa8e99de11dd4437e8a954d153 (diff)
downloadbcm5719-llvm-c2c8bb82096bc938d776557c037cb874de695f80.tar.gz
bcm5719-llvm-c2c8bb82096bc938d776557c037cb874de695f80.zip
Tidy up and improve error recovery for C++11 attributes in bad places. Based on
a patch by Michael Han. llvm-svn: 192666
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index ef1ab89b8c9..f57ff97ceb5 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1314,14 +1314,12 @@ StmtResult Parser::ParseDoStatement() {
return StmtError();
}
- // Parse the parenthesized condition.
+ // Parse the parenthesized expression.
BalancedDelimiterTracker T(*this, tok::l_paren);
T.consumeOpen();
- // FIXME: Do not just parse the attribute contents and throw them away
- ParsedAttributesWithRange attrs(AttrFactory);
- MaybeParseCXX11Attributes(attrs);
- ProhibitAttributes(attrs);
+ // A do-while expression is not a condition, so can't have attributes.
+ DiagnoseAndSkipCXX11Attributes();
ExprResult Cond = ParseExpression();
T.consumeClose();
@@ -2547,9 +2545,10 @@ StmtResult Parser::ParseCXXTryBlockCommon(SourceLocation TryLoc, bool FnTry) {
}
else {
StmtVector Handlers;
- ParsedAttributesWithRange attrs(AttrFactory);
- MaybeParseCXX11Attributes(attrs);
- ProhibitAttributes(attrs);
+
+ // C++11 attributes can't appear here, despite this context seeming
+ // statement-like.
+ DiagnoseAndSkipCXX11Attributes();
if (Tok.isNot(tok::kw_catch))
return StmtError(Diag(Tok, diag::err_expected_catch));
OpenPOWER on IntegriCloud