summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParsePragma.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-02-16 18:36:44 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-02-16 18:36:44 +0000
commit96dae81d7fe7570f97d8fbe03c02e145173f801c (patch)
tree1caa8ac5978d8d350fe3429c2acadba676947b3a /clang/lib/Parse/ParsePragma.cpp
parent79bd39db8098b4092b83931b1ee2cb58dc30499c (diff)
downloadbcm5719-llvm-96dae81d7fe7570f97d8fbe03c02e145173f801c.tar.gz
bcm5719-llvm-96dae81d7fe7570f97d8fbe03c02e145173f801c.zip
[OPENMP] Fix parsing of the directives with inner directives.
The parsing may lead to compiler hanging because of the incorrect processing of inner OpenMP pragmas. llvm-svn: 325369
Diffstat (limited to 'clang/lib/Parse/ParsePragma.cpp')
-rw-r--r--clang/lib/Parse/ParsePragma.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 8cbae5f4633..e815ea13551 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -2117,9 +2117,21 @@ PragmaOpenMPHandler::HandlePragma(Preprocessor &PP,
Tok.setKind(tok::annot_pragma_openmp);
Tok.setLocation(FirstTok.getLocation());
- while (Tok.isNot(tok::eod)) {
+ while (Tok.isNot(tok::eod) && Tok.isNot(tok::eof)) {
Pragma.push_back(Tok);
PP.Lex(Tok);
+ if (Tok.is(tok::annot_pragma_openmp)) {
+ PP.Diag(Tok, diag::err_omp_unexpected_directive) << 0;
+ unsigned InnerPragmaCnt = 1;
+ while (InnerPragmaCnt != 0) {
+ PP.Lex(Tok);
+ if (Tok.is(tok::annot_pragma_openmp))
+ ++InnerPragmaCnt;
+ else if (Tok.is(tok::annot_pragma_openmp_end))
+ --InnerPragmaCnt;
+ }
+ PP.Lex(Tok);
+ }
}
SourceLocation EodLoc = Tok.getLocation();
Tok.startToken();
OpenPOWER on IntegriCloud