[OPENMP] Fix incomplete type check for array reductions
authorJoel E. Denny <jdenny.ornl@gmail.com>
Thu, 28 Jun 2018 19:54:49 +0000 (19:54 +0000)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Thu, 28 Jun 2018 19:54:49 +0000 (19:54 +0000)
A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D48735

llvm-svn: 335911

clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_reduction_messages.c [new file with mode: 0644]

index 7da9df9..6fb0125 100644 (file)
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
     // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
     //  A variable that appears in a private clause must not have an incomplete
     //  type or a reference type.
-    if (S.RequireCompleteType(ELoc, Type,
+    if (S.RequireCompleteType(ELoc, D->getType(),
                               diag::err_omp_reduction_incomplete_type))
       continue;
     // OpenMP [2.14.3.6, reduction clause, Restrictions]
diff --git a/clang/test/OpenMP/parallel_reduction_messages.c b/clang/test/OpenMP/parallel_reduction_messages.c
new file mode 100644 (file)
index 0000000..f88f8e0
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
+
+int incomplete[];
+
+void test() {
+#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction list item with incomplete type 'int []'}}
+  ;
+}
+
+// complete to suppress an additional warning, but it's too late for pragmas
+int incomplete[3];