summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaOpenCL
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2016-04-18 18:40:51 +0000
committerManman Ren <manman.ren@gmail.com>2016-04-18 18:40:51 +0000
commit99d133482f7c7534bf4af6c0c2666b44f5b03a5f (patch)
treed550b13c27f16508c33071c8ad5f30a34c599cc6 /clang/test/SemaOpenCL
parent7f0756cc1fc2a3591f69b498143022055f0d338e (diff)
downloadbcm5719-llvm-99d133482f7c7534bf4af6c0c2666b44f5b03a5f.tar.gz
bcm5719-llvm-99d133482f7c7534bf4af6c0c2666b44f5b03a5f.zip
Block: Fix a crash when we have type attributes or qualifiers with omitted
return type. Emit a warning instead of crashing in IR generation. rdar://22762981 Differential Revision: http://reviews.llvm.org/D18567 llvm-svn: 266648
Diffstat (limited to 'clang/test/SemaOpenCL')
-rw-r--r--clang/test/SemaOpenCL/invalid-block.cl17
1 files changed, 8 insertions, 9 deletions
diff --git a/clang/test/SemaOpenCL/invalid-block.cl b/clang/test/SemaOpenCL/invalid-block.cl
index c8c88219255..98a2e8bdfe5 100644
--- a/clang/test/SemaOpenCL/invalid-block.cl
+++ b/clang/test/SemaOpenCL/invalid-block.cl
@@ -4,16 +4,15 @@
// All blocks declarations must be const qualified and initialized.
void f1() {
- int (^bl1)() = ^() {}; // expected-error{{invalid block variable declaration - must be const qualified}}
+ int (^bl1)() = ^() {return 1;}; // expected-error{{invalid block variable declaration - must be const qualified}}
int (^const bl2)(); // expected-error{{invalid block variable declaration - must be initialized}}
- int (^const bl3)() = ^const(){
- };
+ int (^const bl3)() = ^(){return 1;};
}
// 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)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
void f2() {
- extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+ extern int (^const bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
}
// A block cannot be the return value of a function.
@@ -29,22 +28,22 @@ void f4() {
}
// 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}}
+int (^const bl)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed in OpenCL}}
return 0;
};
// A block can't be used to declare an array
typedef int (^const bl1_t)(int);
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;};
bl1_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl1_t' (aka 'int (^const)(int)') type is invalid in OpenCL}}
int tmp = i ? bl1(i) // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
: bl2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
}
void f6(bl1_t * bl_ptr) {
- bl1_t bl = ^const(int i) {return 1;};
+ bl1_t bl = ^(int i) {return 1;};
bl1_t *p = &bl; // expected-error {{invalid argument type 'bl1_t' (aka 'int (^const)(int)') to unary expression}}
bl = *bl_ptr; // expected-error {{dereferencing pointer of type '__generic bl1_t *' (aka 'int (^const __generic *)(int)') is not allowed in OpenCL}}
}
OpenPOWER on IntegriCloud