[PATCH] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

Manman Ren via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 29 11:54:23 PDT 2016


manmanren created this revision.
manmanren added reviewers: rjmccall, Anastasia.
manmanren added a subscriber: cfe-commits.

A simple example will crash at IRGen:
void (^simpleBlock)() = ^ _Nonnull {
  return;
};

The Return type for the block will be AttributedType of a DependentTy and it will not be resolved. We will get a crash at IRGen.
The fix is to warn when we have type attributes or qualifiers with omitted return type. The type attributes and qualifiers will be ignored.
This breaks test/SemaOpenCL/invalid-block.cl where it uses "^const(){}".
"int (^const bl3)() = ^const(){};" should emit error since we are converting between incompatible block pointer types, the block literal's return type should be void. 

http://reviews.llvm.org/D18567

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaType.cpp
  test/SemaObjC/block-omitted-return-type.m
  test/SemaOpenCL/invalid-block.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18567.51961.patch
Type: text/x-patch
Size: 6107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160329/05578758/attachment-0001.bin>


More information about the cfe-commits mailing list