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