Re: [PATCH] D22075: [OpenMP] Fix incorrect diagnostics in map clause

2016-07-18 Thread David S via cfe-commits
davidsh updated this revision to Diff 64353.
davidsh added a comment.

Fix a typo in code and address test case issues.


https://reviews.llvm.org/D22075

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_for_simd_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp

Index: test/OpenMP/target_parallel_map_messages.cpp
===
--- test/OpenMP/target_parallel_map_messages.cpp
+++ test/OpenMP/target_parallel_map_messages.cpp
@@ -143,13 +143,13 @@
   foo();
 #pragma omp target parallel map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
 {
 #pragma omp target parallel map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
   foo();
 #pragma omp target parallel map(j)
   foo();
-#pragma omp target parallel map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel map(l)
   foo();
 }
 
@@ -246,13 +246,13 @@
   foo();
 #pragma omp target parallel map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 1 {{used here}}
 {
 #pragma omp target parallel map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
   foo();
 #pragma omp target parallel map(j)
   foo();
-#pragma omp target parallel map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel map(l)
   foo();
 }
 
Index: test/OpenMP/target_parallel_for_simd_map_messages.cpp
===
--- test/OpenMP/target_parallel_for_simd_map_messages.cpp
+++ test/OpenMP/target_parallel_for_simd_map_messages.cpp
@@ -143,13 +143,13 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
 {
 #pragma omp target parallel for simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target parallel for simd map(j)
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target parallel for simd map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel for simd map(l)
   for (i = 0; i < argc; ++i) foo();
 }
 
@@ -247,13 +247,13 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 {
 #pragma omp target parallel for simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target parallel for simd map(j)
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target parallel for simd map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel for simd map(l)
   for (i = 0; i < argc; ++i) foo();
 }
 
Index: test/OpenMP/target_parallel_for_map_messages.cpp
===
--- test/OpenMP/target_parallel_for_map_messages.cpp
+++ test/OpenMP/target_parallel_for_map_messages.cpp
@@ -143,13 +143,13 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target parallel for map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
 {
 #pragma omp target parallel for m

[PATCH] D22481: Allow negative lower bound in array sections based on pointers

2016-07-18 Thread David S via cfe-commits
davidsh created this revision.
davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev.
davidsh added a subscriber: cfe-commits.

OpenMP 4.5 removed the restriction that array section lower bound must be non 
negative.
This change is to allow negative values for array section based on pointers.
For array section based on array type there is still a restriction: "The array 
section must be a subset of the original array."

https://reviews.llvm.org/D22481

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/OpenMP/target_depend_messages.cpp
  test/OpenMP/target_enter_data_depend_messages.cpp
  test/OpenMP/target_exit_data_depend_messages.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_depend_messages.cpp
  test/OpenMP/target_parallel_for_depend_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  test/OpenMP/target_parallel_for_simd_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_update_depend_messages.cpp
  test/OpenMP/task_depend_messages.cpp

Index: test/OpenMP/task_depend_messages.cpp
===
--- test/OpenMP/task_depend_messages.cpp
+++ test/OpenMP/task_depend_messages.cpp
@@ -43,7 +43,7 @@
   #pragma omp task depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
   #pragma omp task depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}}
   #pragma omp task depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
-  #pragma omp task depend (in : argv[-1:0]) // expected-error {{section lower bound is evaluated to a negative value -1}}
+  #pragma omp task depend (in : argv[-1:0])
   #pragma omp task depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
   #pragma omp task depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
   #pragma omp task depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
Index: test/OpenMP/target_update_depend_messages.cpp
===
--- test/OpenMP/target_update_depend_messages.cpp
+++ test/OpenMP/target_update_depend_messages.cpp
@@ -50,7 +50,7 @@
   #pragma omp target update to(z) depend(in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
   #pragma omp target update to(z) depend(in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}}
   #pragma omp target update to(z) depend(in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
-  #pragma omp target update to(z) depend(in : argv[-1:0]) // expected-error {{section lower bound is evaluated to a negative value -1}}
+  #pragma omp target update to(z) depend(in : argv[-1:0])
   #pragma omp target update to(z) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
   #pragma omp target update to(z) depend(in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
   #pragma omp target update to(z) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
@@ -98,7 +98,7 @@
   #pragma omp target update to(z) depend(in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
   #pragma omp target update to(z) depend(in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}}
   #pragma omp target update to(z) depend(in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
-  #pragma omp target update to(z) depend(in : argv[-1:0]) // expected-error {{section lower bound is evaluated to a negative value -1}}
+  #pragma omp target update to(z) depend(in : argv[-1:0])
   #pragma omp target update to(z) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
   #pragma omp target update to(z) depend(in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
   #pragma omp target update to(z) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
Index: test/OpenMP/target_parallel_map_messages.cpp
===
--- test/Op

[PATCH] D22487: [OpenMP] Ignore parens in atomic capture

2016-07-18 Thread David S via cfe-commits
davidsh created this revision.
davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev.
davidsh added a subscriber: cfe-commits.

Clang misdiagnoses atomic captures cases that contains parens.
ie.
int v, int *p;
#pragma omp atomic capture
{ v = (*p); (*p)++; }

https://reviews.llvm.org/D22487

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/atomic_messages.c
  test/OpenMP/atomic_messages.cpp

Index: test/OpenMP/atomic_messages.cpp
===
--- test/OpenMP/atomic_messages.cpp
+++ test/OpenMP/atomic_messages.cpp
@@ -453,14 +453,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: test/OpenMP/atomic_messages.c
===
--- test/OpenMP/atomic_messages.c
+++ test/OpenMP/atomic_messages.c
@@ -313,14 +313,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6169,7 +6169,7 @@
 AtomicCompAssignOp->getOpcode());
 OpLoc = AtomicCompAssignOp->getOperatorLoc();
 E = AtomicCompAssignOp->getRHS();
-X = AtomicCompAssignOp->getLHS();
+X = AtomicCompAssignOp->getLHS()->IgnoreParens();
 IsXLHSInRHSPart = true;
   } else if (auto *AtomicBinOp = dyn_cast(
  AtomicBody->IgnoreParenImpCasts())) {
@@ -6183,7 +6183,7 @@
   IsPostfixUpdate = AtomicUnaryOp->isPostfix();
   Op = AtomicUnaryOp->isIncrementOp() ? BO_Add : BO_Sub;
   OpLoc = AtomicUnaryOp->getOperatorLoc();
-  X = AtomicUnaryOp->getSubExpr();
+  X = AtomicUnaryOp->getSubExpr()->IgnoreParens();
   E = SemaRef.ActOnIntegerConstant(OpLoc, /*uint64_t Val=*/1).get();
   IsXLHSInRHSPart = true;
 } else {


Index: test/OpenMP/atomic_messages.cpp
===
--- test/OpenMP/atomic_messages.cpp
+++ test/OpenMP/atomic_messages.cpp
@@ -453,14 +453,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: test/OpenMP/atomic_messages.c
===
--- test/OpenMP/atomic_messages.c
+++ test/OpenMP/atomic_messages.c
@@ -313,14 +313,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6169,7 +6169,7 @@
 AtomicCompAssignOp->getOpcode());
 OpLoc = AtomicCompAssignOp->getOperatorLoc();
 E = AtomicCompAssignOp->getRHS();
-X = AtomicCompAssignOp->getLHS();
+X = AtomicCompAssignOp->getLHS()->IgnoreParens();
 IsXLHSInRHSPart = true;
   } else if (auto *AtomicBinOp = dyn_cast(
  AtomicBody->IgnoreParenImpCasts())) {
@@ -6183,7 +6183,7 @@
   IsPostfixUpdate = AtomicUnaryOp->isPostfix();
   Op = AtomicUnaryOp->isIncrementOp() ? BO_Add : BO_Sub;
   OpLoc = AtomicUnaryOp->getOperatorLoc();
-  X = AtomicUnaryOp->getSubExpr();
+  X = AtomicUnaryOp->getSubExpr()->IgnoreParens();
   E = SemaRef.ActOnIntegerConstant(OpLoc, /*uint64_t Val=*/1).get();
   IsXLHSInRHSPart = true;
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.or

[PATCH] D21617: [OpenMP] Diagnose missing cases of statements between target and teams directives

2016-06-22 Thread David S via cfe-commits
davidsh created this revision.
davidsh added reviewers: kkwli0, hubert.reinterpretcast.
davidsh added a subscriber: cfe-commits.

Clang fails to diagnose cases such as 
#pragma omp target
  while(0) {
#pragma omp teams
{}
  }


http://reviews.llvm.org/D21617

Files:
  lib/Sema/SemaOpenMP.cpp

Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,10 @@
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()))
+OMPTeamsFound = false;
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);


Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,10 @@
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()))
+OMPTeamsFound = false;
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21617: [OpenMP] Diagnose missing cases of statements between target and teams directives

2016-06-22 Thread David S via cfe-commits
davidsh updated this revision to Diff 61612.

http://reviews.llvm.org/D21617

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nesting_of_regions.cpp

Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -2867,6 +2867,12 @@
 #pragma omp teams  // expected-note {{nested teams construct here}}
 ++a;
   }
+#pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
+  {
+while (0)  // expected-note {{statement outside teams construct here}}
+#pragma omp teams  // expected-note {{nested teams construct here}}
+++a;
+  }
 #pragma omp target
   {
 #pragma omp taskloop
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,10 @@
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()))
+OMPTeamsFound = false;
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);


Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -2867,6 +2867,12 @@
 #pragma omp teams  // expected-note {{nested teams construct here}}
 ++a;
   }
+#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
+  {
+while (0)  // expected-note {{statement outside teams construct here}}
+#pragma omp teams  // expected-note {{nested teams construct here}}
+++a;
+  }
 #pragma omp target
   {
 #pragma omp taskloop
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,10 @@
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()))
+OMPTeamsFound = false;
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21617: [OpenMP] Diagnose missing cases of statements between target and teams directives

2016-06-24 Thread David S via cfe-commits
davidsh updated this revision to Diff 61830.
davidsh added a comment.

Address a comment.


http://reviews.llvm.org/D21617

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nesting_of_regions.cpp

Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -2867,6 +2867,12 @@
 #pragma omp teams  // expected-note {{nested teams construct here}}
 ++a;
   }
+#pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
+  {
+while (0)  // expected-note {{statement outside teams construct here}}
+#pragma omp teams  // expected-note {{nested teams construct here}}
+++a;
+  }
 #pragma omp target
   {
 #pragma omp taskloop
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,9 @@
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  OMPTeamsFound = OED && isOpenMPTeamsDirective(OED->getDirectiveKind());
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);


Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -2867,6 +2867,12 @@
 #pragma omp teams  // expected-note {{nested teams construct here}}
 ++a;
   }
+#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
+  {
+while (0)  // expected-note {{statement outside teams construct here}}
+#pragma omp teams  // expected-note {{nested teams construct here}}
+++a;
+  }
 #pragma omp target
   {
 #pragma omp taskloop
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6380,6 +6380,9 @@
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  OMPTeamsFound = OED && isOpenMPTeamsDirective(OED->getDirectiveKind());
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22075: [OpenMP] Fix incorrect diagnostics in map clause

2016-07-06 Thread David S via cfe-commits
davidsh created this revision.
davidsh added reviewers: carlo.bertolli, arpith-jacob, sfantao, ABataev, kkwli0.
davidsh added a subscriber: cfe-commits.

Having the following code pattern will result in incorrect diagnostic
int main() {
int arr[10];
#pragma omp target data map(arr[:])
#pragma omp target map(arr)
{}
}
t.cpp:4:24: error: original storage of expression in data environment is shared 
but data environment do not fully contain mapped expression storage
#pragma omp target map(arr)
   ^~~
t.cpp:3:29: note: used here
#pragma omp target data map(arr[:])
^~
1 error generated.

http://reviews.llvm.org/D22075

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_messages.cpp

Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -284,6 +284,11 @@
 {}
   }
   }
+  #pragma omp target data map(marr[:][:][:])
+  {
+#pragma omp target data map(marr)
+{}
+  }
 
   #pragma omp target data map(to: t)
   {
@@ -488,10 +493,10 @@
 #pragma omp target data map(j)
 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already 
marked as mapped in current construct}} expected-note {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped 
along with a section derived from itself}}
 #pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression 
in data environment is shared but data environment do not fully contain mapped 
expression storage}}
+#pragma omp target map(l)
   foo();
 
 #pragma omp target data map(always, tofrom: x)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10637,6 +10637,24 @@
   if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
 break;
 }
+while(SI != SE) {
+  QualType Type;
+  if (auto *ASE = 
+  dyn_cast(SI->getAssociatedExpression())) {
+Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+  } else if (auto *OASE = 
+   dyn_cast(SI->getAssociatedExpression())) {
+auto *E = OASE->getBase()->IgnoreParenImpCasts();
+Type =
+OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+  }
+  if (!Type.isNull() && !Type->isAnyPointerType() &&
+  !CheckArrayExpressionDoesNotReferToWholeSize(SemaRef,
+   SI->getAssociatedExpression(),Type))
+++SI;
+  else
+break;
+}
 
 // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.4]
 //  List items of map clauses in the same construct must not share


Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -284,6 +284,11 @@
 {}
   }
   }
+  #pragma omp target data map(marr[:][:][:])
+  {
+#pragma omp target data map(marr)
+{}
+  }
 
   #pragma omp target data map(to: t)
   {
@@ -488,10 +493,10 @@
 #pragma omp target data map(j)
 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
 #pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target map(l)
   foo();
 
 #pragma omp target data map(always, tofrom: x)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10637,6 +10637,24 @@
   if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
 break;
 }
+while(SI != SE) {
+  QualType Type;
+  if (auto *ASE = 
+  dyn_cast(SI->getAssociatedExpression())) {
+Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+  } else if (auto *OASE = 
+   dyn_cast(SI->getAssociatedExpression())) {
+auto *E = OASE->getBase()->IgnoreParenImpCasts();
+Type =
+OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType(

Re: [PATCH] D22075: [OpenMP] Fix incorrect diagnostics in map clause

2016-07-07 Thread David S via cfe-commits
davidsh updated this revision to Diff 63090.
davidsh added a comment.

Address comments


http://reviews.llvm.org/D22075

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_messages.cpp

Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -284,6 +284,11 @@
 {}
   }
   }
+  #pragma omp target data map(marr[:][:][:])
+  {
+#pragma omp target data map(marr)
+{}
+  }
 
   #pragma omp target data map(to: t)
   {
@@ -488,10 +493,10 @@
 #pragma omp target data map(j)
 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already 
marked as mapped in current construct}} expected-note {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped 
along with a section derived from itself}}
 #pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression 
in data environment is shared but data environment do not fully contain mapped 
expression storage}}
+#pragma omp target map(l)
   foo();
 
 #pragma omp target data map(always, tofrom: x)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10649,6 +10649,25 @@
   if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
 break;
 }
+// Check if the extra components of the expressions in the enclosing 
+// data environment are redundant for the current base declaration. 
+// If they are, the maps completely overlap, which is legal.
+for (; SI != SE; ++SI) {
+  QualType Type;
+  if (auto *ASE = 
+  dyn_cast(SI->getAssociatedExpression())) {
+Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+  } else if (auto *OASE = 
+   dyn_cast(SI->getAssociatedExpression())) {
+auto *E = OASE->getBase()->IgnoreParenImpCasts();
+Type =
+OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+  }
+  if (Type.isNull() || Type->isAnyPointerType() ||
+  CheckArrayExpressionDoesNotReferToWholeSize(SemaRef,
+  SI->getAssociatedExpression(),Type))
+break;
+}
 
 // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.4]
 //  List items of map clauses in the same construct must not share


Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -284,6 +284,11 @@
 {}
   }
   }
+  #pragma omp target data map(marr[:][:][:])
+  {
+#pragma omp target data map(marr)
+{}
+  }
 
   #pragma omp target data map(to: t)
   {
@@ -488,10 +493,10 @@
 #pragma omp target data map(j)
 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
 #pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target map(l)
   foo();
 
 #pragma omp target data map(always, tofrom: x)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10649,6 +10649,25 @@
   if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
 break;
 }
+// Check if the extra components of the expressions in the enclosing 
+// data environment are redundant for the current base declaration. 
+// If they are, the maps completely overlap, which is legal.
+for (; SI != SE; ++SI) {
+  QualType Type;
+  if (auto *ASE = 
+  dyn_cast(SI->getAssociatedExpression())) {
+Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+  } else if (auto *OASE = 
+   dyn_cast(SI->getAssociatedExpression())) {
+auto *E = OASE->getBase()->IgnoreParenImpCasts();
+Type =
+OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+  }
+  if (Type.isNull() || Type->isAnyPointerType() ||
+  CheckArrayExpressionDoesNotReferToWholeS

Re: [PATCH] D22075: [OpenMP] Fix incorrect diagnostics in map clause

2016-07-13 Thread David S via cfe-commits
davidsh updated this revision to Diff 63824.
davidsh added a comment.

Address formatting comment.


http://reviews.llvm.org/D22075

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_messages.cpp

Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -284,6 +284,11 @@
 {}
   }
   }
+  #pragma omp target data map(marr[:][:][:])
+  {
+#pragma omp target data map(marr)
+{}
+  }
 
   #pragma omp target data map(to: t)
   {
@@ -488,10 +493,10 @@
 #pragma omp target data map(j)
 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already 
marked as mapped in current construct}} expected-note {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped 
along with a section derived from itself}}
 #pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression 
in data environment is shared but data environment do not fully contain mapped 
expression storage}}
+#pragma omp target map(l)
   foo();
 
 #pragma omp target data map(always, tofrom: x)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10649,6 +10649,25 @@
   if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
 break;
 }
+// Check if the extra components of the expressions in the enclosing
+// data environment are redundant for the current base declaration.
+// If they are, the maps completely overlap, which is legal.
+for (; SI != SE; ++SI) {
+  QualType Type;
+  if (auto *ASE =
+  dyn_cast(SI->getAssociatedExpression())) {
+Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+  } else if (auto *OASE =
+  dyn_cast(SI->getAssociatedExpression())) {
+auto *E = OASE->getBase()->IgnoreParenImpCasts();
+Type =
+OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+  }
+  if (Type.isNull() || !Type->isAnyPointerType() ||
+  CheckArrayExpressionDoesNotReferToWholeSize(
+  SemaRef,SI->getAssociatedExpression(),Type))
+break;
+}
 
 // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.4]
 //  List items of map clauses in the same construct must not share


Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -284,6 +284,11 @@
 {}
   }
   }
+  #pragma omp target data map(marr[:][:][:])
+  {
+#pragma omp target data map(marr)
+{}
+  }
 
   #pragma omp target data map(to: t)
   {
@@ -488,10 +493,10 @@
 #pragma omp target data map(j)
 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
   foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
 #pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target map(l)
   foo();
 
 #pragma omp target data map(always, tofrom: x)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10649,6 +10649,25 @@
   if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
 break;
 }
+// Check if the extra components of the expressions in the enclosing
+// data environment are redundant for the current base declaration.
+// If they are, the maps completely overlap, which is legal.
+for (; SI != SE; ++SI) {
+  QualType Type;
+  if (auto *ASE =
+  dyn_cast(SI->getAssociatedExpression())) {
+Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+  } else if (auto *OASE =
+  dyn_cast(SI->getAssociatedExpression())) {
+auto *E = OASE->getBase()->IgnoreParenImpCasts();
+Type =
+OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+  }
+  if (Type.isNull() || !Type->isAnyPointerType() ||
+  CheckArrayExpressionDoesNotReferT