1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LLVM_LICENSE_HEADER@ 5 */ 6 7/* 8 TEST_CONFIG SDK=macosx 9 */ 10 11#import <objc/objc-auto.h> 12#import <Foundation/Foundation.h> 13#import "test.h" 14 15int GlobalInt = 0; 16 17id objc_assign_global(id val __unused, id *dest __unused) { 18 GlobalInt = 1; 19 return (id)0; 20} 21 22id objc_assign_ivar(id val __unused, id dest __unused, ptrdiff_t offset __unused) { 23 GlobalInt = 1; 24 return (id)0; 25} 26 27id objc_assign_strongCast(id val __unused, id *dest __unused) { 28 GlobalInt = 1; 29 return (id)0; 30} 31 32 33//void (^GlobalVoidVoid)(void); 34 35 36int main() { 37 // an object should not be retained within a stack Block 38 __block int i = 0; 39 void (^blockA)(void) __unused = ^ { ++i; }; 40 if (GlobalInt != 0) { 41 fail("write-barrier assignment of stack block"); 42 } 43 44 succeed(__FILE__); 45} 46