summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2017-10-03 20:00:00 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2017-10-03 20:00:00 +0000
commit502ec49793faad5587f8c855a5f8914837594987 (patch)
tree4006aeef99672b41aaed8cb5b03da4e55e360168 /clang/lib
parent56138de385947e1b1c3ea4792c38a10893435b88 (diff)
downloadbcm5719-llvm-502ec49793faad5587f8c855a5f8914837594987.tar.gz
bcm5719-llvm-502ec49793faad5587f8c855a5f8914837594987.zip
[OPENMP] Allow use of declare target directive inside struct
declaration. Patch allows using of the `#pragma omp declare target`| `#pragma omp end declare target` directives inside the structures if we need to mark as declare target only some static members. llvm-svn: 314833
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp14
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp6
2 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 669e9aff802..e1685f6a9db 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -760,9 +760,17 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
DKind = ParseOpenMPDirectiveKind(*this);
while (DKind != OMPD_end_declare_target && DKind != OMPD_declare_target &&
Tok.isNot(tok::eof) && Tok.isNot(tok::r_brace)) {
- ParsedAttributesWithRange attrs(AttrFactory);
- MaybeParseCXX11Attributes(attrs);
- ParseExternalDeclaration(attrs);
+ DeclGroupPtrTy Ptr;
+ // Here we expect to see some function declaration.
+ if (AS == AS_none) {
+ assert(TagType == DeclSpec::TST_unspecified);
+ MaybeParseCXX11Attributes(Attrs);
+ ParsingDeclSpec PDS(*this);
+ Ptr = ParseExternalDeclaration(Attrs, &PDS);
+ } else {
+ Ptr =
+ ParseCXXClassMemberDeclarationWithPragmas(AS, Attrs, TagType, Tag);
+ }
if (Tok.isAnnotation() && Tok.is(tok::annot_pragma_openmp)) {
TentativeParsingAction TPA(*this);
ConsumeAnnotationToken();
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 8bded5854aa..81fea56033c 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11914,7 +11914,11 @@ bool Sema::ActOnStartOpenMPDeclareTargetDirective(SourceLocation Loc) {
DeclContext *CurLexicalContext = getCurLexicalContext();
if (!CurLexicalContext->isFileContext() &&
!CurLexicalContext->isExternCContext() &&
- !CurLexicalContext->isExternCXXContext()) {
+ !CurLexicalContext->isExternCXXContext() &&
+ !isa<CXXRecordDecl>(CurLexicalContext) &&
+ !isa<ClassTemplateDecl>(CurLexicalContext) &&
+ !isa<ClassTemplatePartialSpecializationDecl>(CurLexicalContext) &&
+ !isa<ClassTemplateSpecializationDecl>(CurLexicalContext)) {
Diag(Loc, diag::err_omp_region_not_file_context);
return false;
}
OpenPOWER on IntegriCloud