[PATCH] D48735: [OPENMP] Fix incomplete type check for array reductions

Joel E. Denny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 28 12:04:32 PDT 2018


jdenny created this revision.
jdenny added a reviewer: ABataev.
Herald added a subscriber: guansong.

A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.


Repository:
  rC Clang

https://reviews.llvm.org/D48735

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.c


Index: clang/test/OpenMP/parallel_reduction_messages.c
===================================================================
--- /dev/null
+++ clang/test/OpenMP/parallel_reduction_messages.c
@@ -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];
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -10335,7 +10335,7 @@
     // 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]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48735.153366.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180628/2253f22c/attachment-0001.bin>


More information about the cfe-commits mailing list