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

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 09:22:50 PDT 2016


Anastasia added inline comments.

================
Comment at: test/SemaOpenCL/invalid-block.cl:9
@@ -8,3 +8,3 @@
   int (^const bl2)(); // expected-error{{invalid block variable declaration - must be initialized}}
-  int (^const bl3)() = ^const(){
+  int (^const bl3)() = ^(){ // expected-error{{incompatible block pointer types initializing 'int (^const)()' with an expression of type 'void (^)(void)'}}
   };
----------------
I think this test had a bug initially (multiple actually!). It was meant to initialize with int(^)() expression. Could you please add an int return so that this line has no error. 

================
Comment at: test/SemaOpenCL/invalid-block.cl:9
@@ -8,3 +8,3 @@
   int (^const bl2)(); // expected-error{{invalid block variable declaration - must be initialized}}
-  int (^const bl3)() = ^const(){
+  int (^const bl3)() = ^(){ // expected-error{{incompatible block pointer types initializing 'int (^const)()' with an expression of type 'void (^)(void)'}}
   };
----------------
Anastasia wrote:
> I think this test had a bug initially (multiple actually!). It was meant to initialize with int(^)() expression. Could you please add an int return so that this line has no error. 
I am not getting why this error didn't appear before your change. How does your change trigger this error now, as you seem to be only changing the attributes and not the deduced block type...

================
Comment at: test/SemaOpenCL/invalid-block.cl:14
@@ -13,3 +13,3 @@
 // A block with extern storage class is not allowed.
-extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+extern int (^const bl)() = ^(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
 void f2() {
----------------
The same here, line 7 and 16. Could we return int please.

================
Comment at: test/SemaOpenCL/invalid-block.cl:32
@@ -31,3 +31,3 @@
 // A block with variadic argument is not allowed.
 int (^const bl)(int, ...) = ^const int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed in OpenCL}}
   return 0;
----------------
could you remove second const please?

================
Comment at: test/SemaOpenCL/invalid-block.cl:39
@@ -38,3 +38,3 @@
 void f5(int i) {
-  bl1_t bl1 = ^const(int i) {return 1;};
-  bl1_t bl2 = ^const(int i) {return 2;};
+  bl1_t bl1 = ^(int i) {return 1;};
+  bl1_t bl2 = ^(int i) {return 2;};
----------------
So the return type is deduced to be int for this block expression here?


http://reviews.llvm.org/D18567





More information about the cfe-commits mailing list