objective-c modern translator: more tests.

llvm-svn: 155585
This commit is contained in:
Fariborz Jahanian 2012-04-25 20:48:00 +00:00
parent aa53d680bb
commit 94ee181e08
5 changed files with 81 additions and 1 deletions

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// radar 7692350
void f(void (^block)(void));

View File

@ -0,0 +1,19 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"__declspec(X)=" %t-modern-rw.cpp
// rdar:// 8243071
void x(int y) {}
void f() {
const int bar = 3;
int baz = 4;
__block int bab = 4;
__block const int bas = 5;
void (^b)() = ^{
x(bar);
x(baz);
x(bab);
x(bas);
b();
};
b();
}

View File

@ -0,0 +1,35 @@
// RUN: %clang_cc1 -E %s -o %t.mm
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
// rdar://9006279
void q(void (^p)(void)) {
p();
}
void f() {
__block char BYREF_VAR_CHECK = 'a';
__block char d = 'd';
q(^{
q(^{
__block char e = 'e';
char l = 'l';
BYREF_VAR_CHECK = 'b';
d = 'd';
q(^{
e = '1';
BYREF_VAR_CHECK = '2';
d = '3';
}
);
});
});
}
int main() {
f();
return 0;
}
// CHECK 2: (__Block_byref_BYREF_VAR_CHECK_0 *)BYREF_VAR_CHECK
// CHECK: {(void*)0,(__Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, 0, sizeof(__Block_byref_BYREF_VAR_CHECK_0), 'a'}
// CHECK: __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (__Block_byref_d_1 *)&d, 570425344));

View File

@ -70,3 +70,27 @@ static void initStatics2() {
// rdar://11314329
static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; }
@interface I
{
id list;
}
- (void) Meth;
// radar 7589385 use before definition
- (void) allObjects;
@end
@implementation I
// radar 7589385 use before definition
- (void) allObjects {
__attribute__((__blocks__(byref))) id *listp;
void (^B)(void) = ^(void) {
*listp++ = 0;
};
B();
}
- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; }
@end

View File

@ -1,5 +1,7 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
// radar 7669784
typedef void * id;