mikerice created this revision.
mikerice added reviewers: Anastasia, ABataev, erichkeane, cfe-commits.
Herald added subscribers: guansong, yaxunl.

Compiler crashes when omp simd is used in an OpenCL file:

clang -c -fopenmp omp_simd.cl

__kernel void test(__global int *data, int size) {

  #pragma omp simd
  for (int i = 0; i < size; ++i) {
  }

}

The problem seems to be the check added to verify block pointers have 
initializers.  An OMPCapturedExprDecl is created to capture ‘size’ but there is 
no TypeSourceInfo.

The change just uses getType() directly.


Repository:
  rC Clang

https://reviews.llvm.org/D46667

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/omp_simd.cl


Index: test/SemaOpenCL/omp_simd.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCL/omp_simd.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fopenmp -fsyntax-only -x cl %s
+// expected-no-diagnostics
+
+__kernel void test(__global int *data, int size) {
+  #pragma omp simd
+  for (int i = 0; i < size; ++i) {
+  }
+}
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11345,8 +11345,7 @@
   if (getLangOpts().OpenCL) {
     // OpenCL v2.0 s6.12.5 - Every block variable declaration must have an
     // initialiser
-    if (var->getTypeSourceInfo()->getType()->isBlockPointerType() &&
-        !var->hasInit()) {
+    if (var->getType()->isBlockPointerType() && !var->hasInit()) {
       Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
           << 1 /*Init*/;
       var->setInvalidDecl();


Index: test/SemaOpenCL/omp_simd.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCL/omp_simd.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fopenmp -fsyntax-only -x cl %s
+// expected-no-diagnostics
+
+__kernel void test(__global int *data, int size) {
+  #pragma omp simd
+  for (int i = 0; i < size; ++i) {
+  }
+}
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11345,8 +11345,7 @@
   if (getLangOpts().OpenCL) {
     // OpenCL v2.0 s6.12.5 - Every block variable declaration must have an
     // initialiser
-    if (var->getTypeSourceInfo()->getType()->isBlockPointerType() &&
-        !var->hasInit()) {
+    if (var->getType()->isBlockPointerType() && !var->hasInit()) {
       Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
           << 1 /*Init*/;
       var->setInvalidDecl();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to