60 changes: 30 additions & 30 deletions clang/test/SemaObjC/block-type-safety.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ void f3(void(^f)(Sub *)) {
f(o);
}

void r0(Super* (^f)()) {
void r0(Super* (^f)(void)) {
Super *o = f();
}

void r1(Sub* (^f)()) { // expected-note{{passing argument to parameter 'f' here}}
void r1(Sub* (^f)(void)) { // expected-note{{passing argument to parameter 'f' here}}
Sub *o = f();
}

Expand All @@ -31,19 +31,19 @@ void r2 (id<NSObject> (^f) (void)) {
id o = f();
}

void test1() {
void test1(void) {
f2(^(Sub *o) { }); // expected-error {{incompatible block pointer types passing}}
f3(^(Super *o) { }); // OK, block taking Super* may be called with a Sub*

r0(^Super* () { return 0; }); // OK
r0(^Sub* () { return 0; }); // OK, variable of type Super* gets return value of type Sub*
r0(^id () { return 0; });
r0(^Super* (void) { return 0; }); // OK
r0(^Sub* (void) { return 0; }); // OK, variable of type Super* gets return value of type Sub*
r0(^id (void) { return 0; });

r1(^Super* () { return 0; }); // expected-error {{incompatible block pointer types passing}}
r1(^Sub* () { return 0; }); // OK
r1(^id () { return 0; });
r1(^Super* (void) { return 0; }); // expected-error {{incompatible block pointer types passing}}
r1(^Sub* (void) { return 0; }); // OK
r1(^id (void) { return 0; });

r2(^id<NSObject>() { return 0; });
r2(^id<NSObject>(void) { return 0; });
}


Expand Down Expand Up @@ -103,7 +103,7 @@ void f4(void (^f)(id<P> x)) { // expected-note{{passing argument to parameter 'f
f(b); // expected-warning {{passing 'NSArray<P2> *' to parameter of incompatible type 'id<P>'}}
}

void test3() {
void test3(void) {
f4(^(NSArray<P2>* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}}
}

Expand All @@ -117,8 +117,8 @@ @interface Baz(FooConformance) <Foo>

@implementation Baz @end

int test4 () {
id <Foo> (^b)() = ^{ // Doesn't work
int test4 (void) {
id <Foo> (^b)(void) = ^{ // Doesn't work
return (Baz *)0;
};
return 0;
Expand All @@ -135,7 +135,7 @@ @interface NSAllArray (FooConformance) <Foo>
@end

#ifndef COMPATIBILITY_QUALIFIED_ID_TYPE_CHECKING
int test5() {
int test5(void) {
// Returned value is used outside of a block, so error on changing
// a return type to a more general than expected.
NSAllArray *(^block)(id);
Expand All @@ -158,7 +158,7 @@ int test5() {
// explained in non-compatibility test above, it is not safe in general. But
// to keep existing code working we support a compatibility mode that uses
// previous type checking.
int test5() {
int test5(void) {
NSAllArray *(^block)(id);
id <Foo> (^genericBlock)(id);
genericBlock = block;
Expand All @@ -183,7 +183,7 @@ @interface radar10798770
- (void)sortUsingComparator:(NSComparator)c;
@end

void f() {
void f(void) {
radar10798770 *f;
[f sortUsingComparator:^(id a, id b) {
return NSOrderedSame;
Expand All @@ -194,41 +194,41 @@ void f() {
@protocol P1 @end
@protocol P2 @end

void Test() {
void (^aBlock)();
void Test(void) {
void (^aBlock)(void);
id anId = aBlock; // OK

id<P1,P2> anQualId = aBlock; // expected-error {{initializing 'id<P1,P2>' with an expression of incompatible type 'void (^)()'}}
id<P1,P2> anQualId = aBlock; // expected-error {{initializing 'id<P1,P2>' with an expression of incompatible type 'void (^)(void)'}}

NSArray* anArray = aBlock; // expected-error {{initializing 'NSArray *' with an expression of incompatible type 'void (^)()'}}
NSArray* anArray = aBlock; // expected-error {{initializing 'NSArray *' with an expression of incompatible type 'void (^)(void)'}}

aBlock = anId; // OK

id<P1,P2> anQualId1;
aBlock = anQualId1; // expected-error {{assigning to 'void (^)()' from incompatible type 'id<P1,P2>'}}
aBlock = anQualId1; // expected-error {{assigning to 'void (^)(void)' from incompatible type 'id<P1,P2>'}}

NSArray* anArray1;
aBlock = anArray1; // expected-error {{assigning to 'void (^)()' from incompatible type 'NSArray *'}}
aBlock = anArray1; // expected-error {{assigning to 'void (^)(void)' from incompatible type 'NSArray *'}}
}

void Test2() {
void (^aBlock)();
void Test2(void) {
void (^aBlock)(void);
id<NSObject> anQualId1 = aBlock; // Ok
id<NSObject, NSCopying> anQualId2 = aBlock; // Ok
id<NSObject, NSCopying, NSObject, NSCopying> anQualId3 = aBlock; // Ok
id <P1> anQualId4 = aBlock; // expected-error {{initializing 'id<P1>' with an expression of incompatible type 'void (^)()'}}
id<NSObject, P1, NSCopying> anQualId5 = aBlock; // expected-error {{initializing 'id<NSObject,P1,NSCopying>' with an expression of incompatible type 'void (^)()'}}
id <P1> anQualId4 = aBlock; // expected-error {{initializing 'id<P1>' with an expression of incompatible type 'void (^)(void)'}}
id<NSObject, P1, NSCopying> anQualId5 = aBlock; // expected-error {{initializing 'id<NSObject,P1,NSCopying>' with an expression of incompatible type 'void (^)(void)'}}
id<NSCopying> anQualId6 = aBlock; // Ok
}

void Test3() {
void (^aBlock)();
void Test3(void) {
void (^aBlock)(void);
NSObject *NSO = aBlock; // Ok
NSObject<NSObject> *NSO1 = aBlock; // Ok
NSObject<NSObject, NSCopying> *NSO2 = aBlock; // Ok
NSObject<NSObject, NSCopying, NSObject, NSCopying> *NSO3 = aBlock; // Ok
NSObject <P1> *NSO4 = aBlock; // expected-error {{initializing 'NSObject<P1> *' with an expression of incompatible type 'void (^)()'}}
NSObject<NSObject, P1, NSCopying> *NSO5 = aBlock; // expected-error {{initializing 'NSObject<NSObject,P1,NSCopying> *' with an expression of incompatible type 'void (^)()'}}
NSObject <P1> *NSO4 = aBlock; // expected-error {{initializing 'NSObject<P1> *' with an expression of incompatible type 'void (^)(void)'}}
NSObject<NSObject, P1, NSCopying> *NSO5 = aBlock; // expected-error {{initializing 'NSObject<NSObject,P1,NSCopying> *' with an expression of incompatible type 'void (^)(void)'}}
NSObject<NSCopying> *NSO6 = aBlock; // Ok
}

Expand Down
8 changes: 4 additions & 4 deletions clang/test/SemaObjC/boxing-illegal.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ + (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
int x, y, z;
} point;

void testStruct() {
void testStruct(void) {
point p = { 0, 0, 0 };
id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}}
}

void testPointers() {
void testPointers(void) {
void *null = 0;
id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}}
int numbers[] = { 0, 1, 2 };
id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}}
}

void testInvalid() {
void testInvalid(void) {
@(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}}
}

Expand All @@ -60,7 +60,7 @@ void testEnum(void *p) {
@interface NSString
@end

void testStringLiteral() {
void testStringLiteral(void) {
NSString *s;
s = @("abc");
s = @(u8"abc");
Expand Down
4 changes: 2 additions & 2 deletions clang/test/SemaObjC/builtin_objc_lib_functions.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
// rdar://8592641
Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getClass' with type 'id (const char *)'}} \
Class f0(void) { return objc_getClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getClass' with type 'id (const char *)'}} \
// expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}

// rdar://8735023
Class f1() { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getMetaClass' with type 'id (const char *)'}} \
Class f1(void) { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getMetaClass' with type 'id (const char *)'}} \
// expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}

void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{implicitly declaring library function 'objc_enumerationMutation' with type 'void (id)'}} \
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaObjC/call-unavailable-init-in-self.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (void)subClassContext {

@end

void unrelatedContext() {
void unrelatedContext(void) {
(void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
(void)[Sub new]; // expected-error {{'new' is unavailable}}
}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/SemaOpenCL/array-init.cl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ __kernel void k2(read_only pipe int p) {
reserve_id_t i[] = {i1, i2};
}

event_t create_event();
__kernel void k3() {
event_t create_event(void);
__kernel void k3(void) {
event_t e1 = create_event();
event_t e2 = create_event();
event_t e[] = {e1, e2};
Expand Down
4 changes: 2 additions & 2 deletions clang/test/SemaOpenCL/block-array-capturing.cl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unknown-unknown -emit-llvm %s -o -| FileCheck %s
// expected-no-diagnostics

typedef int (^block_t)();
typedef int (^block_t)(void);

int block_typedef_kernel(global int* res) {
// CHECK: %{{.*}} = alloca <{ i32, i32, i8 addrspace(4)*, [3 x i32] }>
int a[3] = {1, 2, 3};
// CHECK: call void @llvm.memcpy{{.*}}
block_t b = ^() { return a[0]; };
block_t b = ^(void) { return a[0]; };
return b();
}

Expand Down
20 changes: 10 additions & 10 deletions clang/test/SemaOpenCL/invalid-block.cl
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s
// RUN: %clang_cc1 -verify -fblocks -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_device_enqueue,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables %s
// OpenCL v2.0 s6.12.5
void f0(int (^const bl)()); // expected-error{{declaring function parameter of type 'int (__generic ^const __private)(void)' is not allowed}}
void f0(int (^const bl)(void)); // expected-error{{declaring function parameter of type 'int (__generic ^const __private)(void)' is not allowed}}
// All blocks declarations must be const qualified and initialized.
void f1() {
int (^bl1)(void) = ^() {
void f1(void) {
int (^bl1)(void) = ^(void) {
return 1;
};
int (^const bl2)(void) = ^() {
int (^const bl2)(void) = ^(void) {
return 1;
};
f0(bl1);
f0(bl2);
bl1 = bl2; // expected-error{{invalid operands to binary expression ('int (__generic ^const __private)(void)' and 'int (__generic ^const __private)(void)')}}
int (^const bl3)(); // expected-error{{invalid block variable declaration - must be initialized}}
int (^const bl3)(void); // expected-error{{invalid block variable declaration - must be initialized}}
}

// A block with extern storage class is not allowed.
extern int (^bl)(void) = ^() { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
extern int (^bl)(void) = ^(void) { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
return 1;
};
void f2() {
extern int (^bl)(void) = ^() { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
extern int (^bl)(void) = ^(void) { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
return 1;
};
}
Expand All @@ -32,9 +32,9 @@ bl_t f3a(int); // expected-error{{declaring function return value of type 'b
bl_t f3b(bl_t bl);
// expected-error@-1{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}}
// expected-error@-2{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
void f3c() {
void f3c(void) {
// Block with a block argument.
int (^const bl2)(bl_t block_arg) = ^() { // expected-error{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
int (^const bl2)(bl_t block_arg) = ^(void) { // expected-error{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
return block_arg(); // expected-error{{implicit declaration of function 'block_arg' is invalid in OpenCL}}
};
}
Expand Down Expand Up @@ -76,7 +76,7 @@ void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type 'bl2_t' (aka 'int (_
&bl; // expected-error {{invalid argument type '__private bl2_t' (aka 'int (__generic ^const __private)(__private int)') to unary expression}}
}
// A block can't reference another block
kernel void f7() {
kernel void f7(void) {
bl2_t bl1 = ^(int i) {
return 1;
};
Expand Down
6 changes: 3 additions & 3 deletions clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
global pipe int gp; // expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
global reserve_id_t rid; // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}

extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
extern pipe write_only int get_pipe(void); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_program_scope_global_variables))
// expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
#else
Expand All @@ -25,7 +25,7 @@ void test2(pipe p) {// expected-error {{missing actual type specifier for pipe}}
}
void test3(int pipe p) {// expected-error {{cannot combine with previous 'int' declaration specifier}}
}
void test4() {
void test4(void) {
pipe int p; // expected-error {{type '__private read_only pipe int' can only be used as a function parameter}}
//TODO: fix parsing of this pipe int (*p);
}
Expand All @@ -38,7 +38,7 @@ void test5(pipe int p) {
}

typedef pipe int pipe_int_t;
pipe_int_t test6() {} // expected-error{{declaring function return value of type 'pipe_int_t' (aka 'read_only pipe int') is not allowed}}
pipe_int_t test6(void) {} // expected-error{{declaring function return value of type 'pipe_int_t' (aka 'read_only pipe int') is not allowed}}

bool test_id_comprision(void) {
reserve_id_t id1, id2;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaOpenCL/nosvm.cl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kernel void f(__attribute__((nosvm)) global int* a);
// expected-error@-6 {{attribute 'nosvm' is supported in the OpenCL version 2.0 onwards}}
#endif

__attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
__attribute__((nosvm)) void g(void); // expected-warning {{'nosvm' attribute only applies to variables}}

#else
void f(__attribute__((nosvm)) int* a); // expected-warning {{'nosvm' attribute ignored}}
Expand Down
10 changes: 5 additions & 5 deletions clang/test/SemaOpenCL/null_queue.cl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
extern queue_t get_default_queue();
extern queue_t get_default_queue(void);

void queue_arg(queue_t); // expected-note {{passing argument to parameter here}}

void init() {
void init(void) {
queue_t q1 = 1; // expected-error{{initializing '__private queue_t' with an expression of incompatible type 'int'}}
queue_t q = 0;
}

void assign() {
void assign(void) {
queue_t q2, q3;
q2 = 5; // expected-error{{assigning to '__private queue_t' from incompatible type 'int'}}
q3 = 0;
q2 = q3 = 0;
}

bool compare() {
bool compare(void) {
queue_t q4, q5;
return 1 == get_default_queue() && // expected-error{{invalid operands to binary expression ('int' and 'queue_t')}}
get_default_queue() == 1 && // expected-error{{invalid operands to binary expression ('queue_t' and 'int')}}
Expand All @@ -24,7 +24,7 @@ bool compare() {
q4 != 0.0f; // expected-error{{invalid operands to binary expression ('__private queue_t' and 'float')}}
}

void call() {
void call(void) {
queue_arg(5); // expected-error {{passing 'int' to parameter of incompatible type 'queue_t'}}
queue_arg(0);
}