r244719 - [OPENMP] Fix for http://llvm.org/PR24430: clang hangs on invalid input with openmp directive
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 12 00:10:55 PDT 2015
Author: abataev
Date: Wed Aug 12 02:10:54 2015
New Revision: 244719
URL: http://llvm.org/viewvc/llvm-project?rev=244719&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/OpenMP/openmp_common.c
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=244719&r1=244718&r2=244719&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Aug 12 02:10:54 2015
@@ -3615,6 +3615,14 @@ void Parser::ParseStructUnionBody(Source
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.
Modified: cfe/trunk/test/OpenMP/openmp_common.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_common.c?rev=244719&r1=244718&r2=244719&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/openmp_common.c (original)
+++ cfe/trunk/test/OpenMP/openmp_common.c Wed Aug 12 02:10:54 2015
@@ -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;
+
More information about the cfe-commits
mailing list