From 2819260b357e7fdb66550a3737cc57f1a1aa09d6 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 27 Feb 2018 17:42:00 +0000 Subject: [PATCH] [OPENMP] Allow multiple mappings for member expressions for pointers. If several member expressions are mapped and they reference the same address as a base, but access different members, this must be allowed. llvm-svn: 326212 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++-- clang/lib/Sema/SemaOpenMP.cpp | 16 +++++++++++----- clang/test/OpenMP/target_map_messages.cpp | 12 ++++++++++-- clang/test/OpenMP/target_teams_map_messages.cpp | 12 ++++++++++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 04e3d46..4fd75b0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8646,8 +8646,8 @@ def err_omp_pointer_mapped_along_with_derived_section : Error< "pointer cannot be mapped along with a section derived from itself">; def err_omp_original_storage_is_shared_and_does_not_contain : Error< "original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage">; -def err_omp_same_pointer_derreferenced : Error< - "same pointer derreferenced in multiple different ways in map clause expressions">; +def err_omp_same_pointer_dereferenced : Error< + "same pointer dereferenced in multiple different ways in map clause expressions">; def note_omp_task_predetermined_firstprivate_here : Note< "predetermined as a firstprivate in a task construct here">; def err_omp_threadprivate_incomplete_type : Error< diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 88c993d..7421da4 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -11987,14 +11987,20 @@ static bool CheckMapConflicts( DerivedLoc, diag::err_omp_pointer_mapped_along_with_derived_section) << DerivedLoc; - } else { + SemaRef.Diag(RE->getExprLoc(), diag::note_used_here) + << RE->getSourceRange(); + return true; + } else if (CI->getAssociatedExpression()->getStmtClass() != + SI->getAssociatedExpression()->getStmtClass() || + CI->getAssociatedDeclaration()->getCanonicalDecl() == + SI->getAssociatedDeclaration()->getCanonicalDecl()) { assert(CI != CE && SI != SE); - SemaRef.Diag(DerivedLoc, diag::err_omp_same_pointer_derreferenced) + SemaRef.Diag(DerivedLoc, diag::err_omp_same_pointer_dereferenced) << DerivedLoc; + SemaRef.Diag(RE->getExprLoc(), diag::note_used_here) + << RE->getSourceRange(); + return true; } - SemaRef.Diag(RE->getExprLoc(), diag::note_used_here) - << RE->getSourceRange(); - return true; } // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.4] diff --git a/clang/test/OpenMP/target_map_messages.cpp b/clang/test/OpenMP/target_map_messages.cpp index 72bd35e..ce14b857 100644 --- a/clang/test/OpenMP/target_map_messages.cpp +++ b/clang/test/OpenMP/target_map_messages.cpp @@ -235,9 +235,17 @@ void SAclient(int arg) { {} #pragma omp target map(r.ArrS[0].A, t.ArrS[1].A) {} - #pragma omp target map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer derreferenced in multiple different ways in map clause expressions}} expected-note {{used here}} + #pragma omp target map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}} {} - #pragma omp target map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer derreferenced in multiple different ways in map clause expressions}} expected-note {{used here}} + #pragma omp target map(r.PtrS, r.PtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} + {} + #pragma omp target map(r.PtrS->A, r.PtrS->B) + {} + #pragma omp target map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}} + {} + #pragma omp target map(r.RPtrS, r.RPtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} + {} + #pragma omp target map(r.RPtrS->A, r.RPtrS->B) {} #pragma omp target map(r.S.Arr[:12]) {} diff --git a/clang/test/OpenMP/target_teams_map_messages.cpp b/clang/test/OpenMP/target_teams_map_messages.cpp index 0fa7a9e..896682a 100644 --- a/clang/test/OpenMP/target_teams_map_messages.cpp +++ b/clang/test/OpenMP/target_teams_map_messages.cpp @@ -225,9 +225,17 @@ void SAclient(int arg) { {} #pragma omp target teams map(r.ArrS[0].A, t.ArrS[1].A) {} - #pragma omp target teams map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer derreferenced in multiple different ways in map clause expressions}} expected-note {{used here}} + #pragma omp target teams map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}} {} - #pragma omp target teams map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer derreferenced in multiple different ways in map clause expressions}} expected-note {{used here}} + #pragma omp target teams map(r.PtrS, r.PtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} + {} + #pragma omp target teams map(r.PtrS->A, r.PtrS->B) + {} + #pragma omp target teams map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}} + {} + #pragma omp target teams map(r.RPtrS, r.RPtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} + {} + #pragma omp target teams map(r.RPtrS->A, r.RPtrS->B) {} #pragma omp target teams map(r.S.Arr[:12]) {} -- 2.7.4