Author: Ritanya B Bharadwaj Date: 2023-08-08T10:14:59-05:00 New Revision: 58eba709a330e4c83de0a98b50fc0acf26cb4344
URL: https://github.com/llvm/llvm-project/commit/58eba709a330e4c83de0a98b50fc0acf26cb4344 DIFF: https://github.com/llvm/llvm-project/commit/58eba709a330e4c83de0a98b50fc0acf26cb4344.diff LOG: [OpenMP] supporting additional case of declare target initializer expression list Added: Modified: clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/declare_target_variables_ast_print.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 3482cafbc74aa1..404b21559559f1 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -23257,6 +23257,10 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc, if (ASTMutationListener *ML = Context.getASTMutationListener()) ML->DeclarationMarkedOpenMPDeclareTarget(ND, A); checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc); + if (auto *VD = dyn_cast<VarDecl>(ND); + LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() && + VD->hasGlobalStorage()) + ActOnOpenMPDeclareTargetInitializer(ND); } static void checkDeclInTargetContext(SourceLocation SL, SourceRange SR, diff --git a/clang/test/OpenMP/declare_target_variables_ast_print.cpp b/clang/test/OpenMP/declare_target_variables_ast_print.cpp index 1e37efe20989c7..cd5dfea56f8f35 100644 --- a/clang/test/OpenMP/declare_target_variables_ast_print.cpp +++ b/clang/test/OpenMP/declare_target_variables_ast_print.cpp @@ -27,6 +27,10 @@ struct target{ }; static target S; +static int var3 = 100; +static int *ptr_3 = &var3; +static char c = 'a'; + #pragma omp declare target int target_var = variable; float target_var1 = variable2; @@ -36,6 +40,9 @@ int (**ptr3)[2] = &arrptr; declare **obj3 = &obj2; target *S1 = &S; #pragma omp end declare target +#pragma omp declare target(ptr_3) +#pragma omp declare target to(c) + // CHECK: #pragma omp declare target // CHECK-NEXT: static int variable = 100; // CHECK-NEXT: #pragma omp end declare target @@ -87,7 +94,15 @@ target *S1 = &S; // CHECK-NEXT: #pragma omp declare target // CHECK-NEXT: static target S; // CHECK-NEXT: #pragma omp end declare target - +// CHECK-NEXT: #pragma omp declare target +// CHECK-NEXT: static int var3 = 100; +// CHECK-NEXT: #pragma omp end declare target +// CHECK-NEXT: #pragma omp declare target +// CHECK-NEXT: static int *ptr_3 = &var3; +// CHECK-NEXT: #pragma omp end declare target +// CHECK-NEXT: #pragma omp declare target +// CHECK-NEXT: static char c = 'a'; +// CHECK-NEXT: #pragma omp end declare target // CHECK-NEXT: #pragma omp declare target // CHECK-NEXT: int target_var = variable; // CHECK-NEXT: #pragma omp end declare target _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits