diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index 66346bf40193f..a50042f6e1434 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -367,6 +367,7 @@ features cannot lower the translation-unit ABI level; non-type template parameter. (#GH212351) - Fixed an assertion crash when instantiating a nested requirement with an invalid constraint. (#GH213575) - Clang now defines the GCC-compatible predefined macro `__SIG_ATOMIC_TYPE__`. (#GH213895) +- Fixed a bug where a stray closing curley brace in an OpenMP/OpenACC pragma could cause pragma parsing issues when inside of a member function. (#GH214195) #### Bug Fixes to Compiler Builtins diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index be531e567046e..3f101feb26a6d 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -870,6 +870,27 @@ bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, // Ran out of tokens. return false; + case tok::annot_pragma_openacc: + case tok::annot_pragma_openmp: + case tok::annot_attr_openmp: { + // Ignore any tokens inside of a OMP/OpenACC pragma, as these should just + // be taken as 1. + tok::TokenKind EndKind = Tok.is(tok::annot_pragma_openacc) + ? tok::annot_pragma_openacc_end + : tok::annot_pragma_openmp_end; + Toks.push_back(Tok); + ConsumeAnnotationToken(); + while (Tok.isNot(EndKind) && Tok.isNot(tok::eof)) { + Toks.push_back(Tok); + ConsumeAnyToken(); + } + if (Tok.is(EndKind)) { + Toks.push_back(Tok); + ConsumeAnnotationToken(); + } + break; + } + case tok::l_paren: // Recursively consume properly-nested parens. Toks.push_back(Tok); diff --git a/clang/test/OpenMP/gh214195.cpp b/clang/test/OpenMP/gh214195.cpp new file mode 100644 index 0000000000000..3247922412beb --- /dev/null +++ b/clang/test/OpenMP/gh214195.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -fopenmp + +struct Type { + void foo() { +#pragma omp parallel private(bar }) + // expected-error@-1{{use of undeclared identifier 'bar'}} + // expected-error@+1{{expected statement}} + } +}; diff --git a/clang/test/ParserOpenACC/parse-constructs.cpp b/clang/test/ParserOpenACC/parse-constructs.cpp index 6d6285ce63bd2..abe3de899abc9 100644 --- a/clang/test/ParserOpenACC/parse-constructs.cpp +++ b/clang/test/ParserOpenACC/parse-constructs.cpp @@ -58,3 +58,10 @@ void foo() { auto y = [](){}; #pragma acc routine (x) seq } + +struct GH214195 { + void foo() { +#pragma acc cache(bar }) + // expected-error@-1{{use of undeclared identifier 'bar'}} + } +};