From: Alexey Bataev Date: Wed, 12 Aug 2015 07:10:54 +0000 (+0000) Subject: [OPENMP] Fix for http://llvm.org/PR24430: clang hangs on invalid input with openmp... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ba21757c987b056360c8ea9fa6c30c148404d17;p=clang [OPENMP] Fix for http://llvm.org/PR24430: clang hangs on invalid input with openmp directive Add parsing of openmp directives inside structs/unions in C mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244719 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 40687d8f27..debbd50d66 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3615,6 +3615,14 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, continue; } + if (Tok.is(tok::annot_pragma_openmp)) { + // Result can be ignored, because it must be always empty. + auto Res = ParseOpenMPDeclarativeDirective(); + assert(!Res); + // Silence possible warnings. + (void)Res; + continue; + } if (!Tok.is(tok::at)) { auto CFieldCallback = [&](ParsingFieldDeclarator &FD) { // Install the declarator into the current TagDecl. diff --git a/test/OpenMP/openmp_common.c b/test/OpenMP/openmp_common.c index 3765f4c5dc..ed55796b33 100644 --- a/test/OpenMP/openmp_common.c +++ b/test/OpenMP/openmp_common.c @@ -7,3 +7,8 @@ void foo() { #pragma omp // expected-error {{expected an OpenMP directive}} #pragma omp unknown_directive // expected-error {{expected an OpenMP directive}} } + +typedef struct S { +#pragma omp parallel for private(j) schedule(static) if (tree1->totleaf > 1024) // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}} +} St; +