From 8b9cb9833f323c3d591ad3266d671a1602d9f649 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 24 Jul 2014 02:33:58 +0000 Subject: [PATCH] [OPENMP] Fixed DSA detecting for function parameters: by default they must be private. llvm-svn: 213835 --- clang/lib/Sema/SemaOpenMP.cpp | 8 +++++--- clang/test/OpenMP/single_copyprivate_messages.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 0dbdf16..9c05e92 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -226,7 +226,7 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(StackTy::reverse_iterator Iter, // File-scope or namespace-scope variables referenced in called routines // in the region are shared unless they appear in a threadprivate // directive. - if (!D->isFunctionOrMethodVarDecl()) + if (!D->isFunctionOrMethodVarDecl() && !isa(D)) DVar.CKind = OMPC_shared; // OpenMP [2.9.1.2, Data-sharing Attribute Rules for Variables Referenced @@ -393,8 +393,10 @@ DSAStackTy::DSAVarData DSAStackTy::getTopDSA(VarDecl *D, bool FromParent) { StartI = std::next(StartI); } if (!isParallelOrTaskRegion(Kind)) { - if (isOpenMPLocal(D, StartI) && D->isLocalVarDecl() && - (D->getStorageClass() == SC_Auto || D->getStorageClass() == SC_None)) { + if (isOpenMPLocal(D, StartI) && + ((D->isLocalVarDecl() && (D->getStorageClass() == SC_Auto || + D->getStorageClass() == SC_None)) || + isa(D))) { DVar.CKind = OMPC_private; return DVar; } diff --git a/clang/test/OpenMP/single_copyprivate_messages.cpp b/clang/test/OpenMP/single_copyprivate_messages.cpp index f07ab12..7bb145c 100644 --- a/clang/test/OpenMP/single_copyprivate_messages.cpp +++ b/clang/test/OpenMP/single_copyprivate_messages.cpp @@ -155,3 +155,23 @@ int main(int argc, char **argv) { return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} } + +extern void abort(void); + +void +single(int a, int b) { +#pragma omp single copyprivate(a) copyprivate(b) + { + a = b = 5; + } + + if (a != b) + abort(); +} + +int parallel() { +#pragma omp parallel + single(1, 2); + + return 0; +} -- 2.7.4