diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-10-28 22:04:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-10-28 22:04:30 +0000 |
commit | 426a47bddb7962c1d1e1c9cb8e3b6807aa619e91 (patch) | |
tree | e30b6385492da6a39e9dfb7675337a2d8d0e93c2 /clang/lib/Parse/ParseStmt.cpp | |
parent | 4404eb4857ef93f9cf5dc5f7cb274d979838c5aa (diff) | |
download | bcm5719-llvm-426a47bddb7962c1d1e1c9cb8e3b6807aa619e91.tar.gz bcm5719-llvm-426a47bddb7962c1d1e1c9cb8e3b6807aa619e91.zip |
Fix a parser crash when there are #pragmas in a context which requires a single
statement (after a case label, if, etc). Patch by Olivier Goffart!
llvm-svn: 193545
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index f57ff97ceb5..caf0011dba9 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -41,6 +41,21 @@ using namespace clang; // C99 6.8: Statements and Blocks. //===----------------------------------------------------------------------===// +/// \brief Parse a standalone statement (for instance, as the body of an 'if', +/// 'while', or 'for'). +StmtResult Parser::ParseStatement(SourceLocation *TrailingElseLoc) { + StmtResult Res; + + // We may get back a null statement if we found a #pragma. Keep going until + // we get an actual statement. + do { + StmtVector Stmts; + Res = ParseStatementOrDeclaration(Stmts, true, TrailingElseLoc); + } while (!Res.isInvalid() && !Res.get()); + + return Res; +} + /// ParseStatementOrDeclaration - Read 'statement' or 'declaration'. /// StatementOrDeclaration: /// statement |