diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-13 18:00:54 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-13 18:00:54 +0000 |
commit | 653b7cff0efe0d32ab12535846196e3465445fef (patch) | |
tree | d6c8096e30a021a6c2b38926c6e2981b8e4ffe7e /test | |
parent | c6b468e46d467eb8d0bcfdbbcc776ef9650133a0 (diff) |
modern objective-c translator: Fixes translation of
__typeof which is a regression by reverting
r154360. // rdar://11233924
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154679 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Rewriter/objc-modern-implicit-cast.mm | 1 | ||||
-rw-r--r-- | test/Rewriter/rewrite-modern-typeof.mm | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/Rewriter/objc-modern-implicit-cast.mm b/test/Rewriter/objc-modern-implicit-cast.mm index e6121991e5..33c5b73882 100644 --- a/test/Rewriter/objc-modern-implicit-cast.mm +++ b/test/Rewriter/objc-modern-implicit-cast.mm @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://11202764 +// XFAIL: * typedef void(^BL)(void); diff --git a/test/Rewriter/rewrite-modern-typeof.mm b/test/Rewriter/rewrite-modern-typeof.mm new file mode 100644 index 0000000000..4650ab7b7f --- /dev/null +++ b/test/Rewriter/rewrite-modern-typeof.mm @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp + +extern "C" { +extern "C" void *_Block_copy(const void *aBlock); +extern "C" void _Block_release(const void *aBlock); +} + +int main() { + __attribute__((__blocks__(byref))) int a = 42; + int save_a = a; + + void (^b)(void) = ^{ + ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; }))); + }; + + ((__typeof(b))_Block_copy((const void *)(b))); + + return 0; +} + +// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b))) + +// radar 7628153 +void f() { + int a; + __typeof__(a) aVal = a; + char *a1t = (char *)@encode(__typeof__(a)); + __typeof__(aVal) bVal; + char *a2t = (char *)@encode(__typeof__(bVal)); + __typeof__(bVal) cVal = bVal; + char *a3t = (char *)@encode(__typeof__(cVal)); + +} + +// rdar://11239324 +void x() { + id y; + void (^z)() = ^{ }; + y = (id)((__typeof(z))_Block_copy((const void *)(z))); +} + +// CHECK-LP: int aVal = a; + +// CHECK-LP: int bVal; |