[PATCH] D46667: [OpenCL, OpenMP] Fix crash when OpenMP used in OpenCL file
Mike Rice via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 9 17:28:44 PDT 2018
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46667.146037.patch
Type: text/x-patch
Size: 969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180510/6e2f28b7/attachment.bin>
More information about the cfe-commits
mailing list