brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 33e4009 Raw
84 lines · plain
1// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -std=c++11 -emit-llvm -o %t2 3@interface A4@end5 6@interface B : A7@end8 9void f(int (^bl)(B* b));10void takeBlock(void (^block)());11void useValues(...);12 13// Test114void g() {15  f(^(A* a) { return 0; });16}17 18// Test219void g1() {20  int (^bl)(B* b) = ^(A* a) { return 0; };21}22 23// Test324@protocol NSObject;25 26void bar(id(^)(void));27 28void foo(id <NSObject>(^objectCreationBlock)(void)) {29    return bar(objectCreationBlock);30}31 32// Test433struct S {34  S *(^a)() = ^{35    return this;36  };37};38S s;39 40// Test541struct X {42  void f() {43    ^ {44      struct Nested { Nested *ptr = this; };45    } ();46  };47};48 49// Regression test for PR1331450class FooClass { };51void fun() {52  FooClass foovar;53  ^() {  // expected-warning {{expression result unused}}54    return foovar;55  };56}57void gun() {58  FooClass foovar;59  [=]() {  // expected-warning {{expression result unused}}60    return foovar;61  };62}63 64// PR2478065class CaptureThisAndAnotherPointer {66  void test(void *ptr) {67    takeBlock(^{ useValues(ptr, this); });68  }69};70 71// Check that we don't crash when using BLOCK_LAYOUT_STRONG.72#pragma clang assume_nonnull begin73@interface NSUUID @end74#pragma clang assume_nonnull end75 76struct Wrapper1 { NSUUID *Ref; };77struct Wrapper2 { Wrapper1 W1; };78 79@implementation B80- (void) captureStrongRef {81  __block Wrapper2 W2;82}83@end84