<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - ExprWithCleanups not handled in emitOpenCLEnqueuedBlock"
   href="https://bugs.llvm.org/show_bug.cgi?id=36088">36088</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ExprWithCleanups not handled in emitOpenCLEnqueuedBlock
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>OpenCL
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>llvm@zaghen.it
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19749" name="attach_19749" title="The CL kernel">attachment 19749</a> <a href="attachment.cgi?id=19749&action=edit" title="The CL kernel">[details]</a></span>
The CL kernel

The attached source makes clang (6.0-rc1 and trunk) assert on
cast<BlockExpr>().
I tried ignoring the ExprWithCleanups:

   if (auto DR = dyn_cast<DeclRefExpr>(E)) {
     E = cast<VarDecl>(DR->getDecl())->getInit();
   }
+  if (auto Cast = dyn_cast<ExprWithCleanups>(E)) {
+    E = Cast->getSubExpr();
+  }
   if (auto Cast = dyn_cast<CastExpr>(E)) {
     E = Cast->getSubExpr();
   }
   auto *Block = cast<BlockExpr>(E);

but it seems like clang also tries to emit the same block expression twice (the
second time through the OCL enqueue specific codepath.)

Options I used for clang: "-x cl -cl-std=CL2.0 enqueue_block_kernel.cl"</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>