]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fixed detection of canonical loops with random access iterators.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 16 Jul 2015 04:19:43 +0000 (04:19 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 16 Jul 2015 04:19:43 +0000 (04:19 +0000)
Add handling of iterators with copy/move constructors with default arguments + converting template constructors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242382 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/for_codegen.cpp
test/OpenMP/for_loop_messages.cpp
test/OpenMP/for_simd_loop_messages.cpp
test/OpenMP/parallel_for_loop_messages.cpp
test/OpenMP/parallel_for_simd_loop_messages.cpp
test/OpenMP/simd_loop_messages.cpp

index 239ede5bb65bc75be596f4dd011748f05f5fc8b3..e11ab82f88c5c10bf8986b157809defc336ab4fd 100644 (file)
@@ -2290,8 +2290,9 @@ bool OpenMPIterationSpaceChecker::SetVarAndLB(VarDecl *NewVar,
   VarRef = NewVarRefExpr;
   if (auto *CE = dyn_cast_or_null<CXXConstructExpr>(NewLB))
     if (const CXXConstructorDecl *Ctor = CE->getConstructor())
-      if (Ctor->isCopyConstructor() && CE->getNumArgs() == 1 &&
-          CE->getArg(0) != nullptr)
+      if ((Ctor->isCopyOrMoveConstructor() ||
+           Ctor->isConvertingConstructor(/*AllowExplicit=*/false)) &&
+          CE->getNumArgs() > 0 && CE->getArg(0) != nullptr)
         NewLB = CE->getArg(0)->IgnoreParenImpCasts();
   LB = NewLB;
   return false;
@@ -2426,8 +2427,9 @@ static const VarDecl *GetInitVarDecl(const Expr *E) {
   E = getExprAsWritten(E);
   if (auto *CE = dyn_cast_or_null<CXXConstructExpr>(E))
     if (const CXXConstructorDecl *Ctor = CE->getConstructor())
-      if (Ctor->isCopyConstructor() && CE->getNumArgs() == 1 &&
-          CE->getArg(0) != nullptr)
+      if ((Ctor->isCopyOrMoveConstructor() ||
+           Ctor->isConvertingConstructor(/*AllowExplicit=*/false)) &&
+          CE->getNumArgs() > 0 && CE->getArg(0) != nullptr)
         E = CE->getArg(0)->IgnoreParenImpCasts();
   auto DRE = dyn_cast_or_null<DeclRefExpr>(E);
   if (!DRE)
index 539fb7bf02b280d0474c88c14f3da4006fe1a34b..7f7e9ba9d2530e0009c56f304b68e5242a5fd81e 100644 (file)
@@ -420,8 +420,9 @@ struct Bool {
 template <typename T>
 struct It {
   It() : p(0) {}
-  It(const It &) ;
-  It(It &) ;
+  It(const It &, int = 0) ;
+  template <typename U>
+  It(U &, int = 0) ;
   It &operator=(const It &);
   It &operator=(It &);
   ~It() {}
index f425defdf3e2bda29ff97d3b8a0ee9289de2b29e..ba27934b11d8c5340b7029f879d6d19e0045a565 100644 (file)
@@ -562,7 +562,7 @@ int test_with_random_access_iterator() {
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
 #pragma omp parallel
-// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 // Initializer is constructor with all default params.
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
index 6e68eb8a082d07f45158a9c4545f3a63bf1643c5..99b8339840b477f0c8353618320569434179130c 100644 (file)
@@ -544,7 +544,7 @@ int test_with_random_access_iterator() {
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
 #pragma omp parallel
-// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 // Initializer is constructor with all default params.
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
index 09a15e2dc33792d7b18cb7f14fa84784a2860587..8c0cdf8e9ed777e61a05ee62c132dfc5a5779e73 100644 (file)
@@ -467,7 +467,7 @@ int test_with_random_access_iterator() {
 #pragma omp parallel for
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
-// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 // Initializer is constructor with all default params.
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
index 0473b248a69dc56df7375f83688b87efd4782419..94bd37c596e142f98fb2d4924d449d570e5d98ce 100644 (file)
@@ -467,7 +467,7 @@ int test_with_random_access_iterator() {
 #pragma omp parallel for simd
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
-// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 // Initializer is constructor with all default params.
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
index fe8e70a9b8a028cf7c235f79585bb9e557804539..bd7dd5bf52d11379247830a89f148deac6cc07cb 100644 (file)
@@ -456,7 +456,7 @@ int test_with_random_access_iterator() {
     ++I;
 
   // Initializer is constructor with all default params.
-  // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+  // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}}
   // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
   // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
   #pragma omp simd