1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LLVM_LICENSE_HEADER@ 5 */ 6 7// 8// recursive-assign-int.m 9// testObjects 10// 11// Created by Blaine Garst on 12/4/08. 12// Copyright 2008 __MyCompanyName__. All rights reserved. 13// 14 15// TEST_CONFIG rdar://6416474 16 17// The compiler is prefetching x->forwarding before evaluting code that recomputes forwarding and so the value goes to a place that is never seen again. 18 19#include <stdio.h> 20#include <stdlib.h> 21#include <Block.h> 22#include "test.h" 23 24typedef void (^blockOfVoidReturningVoid)(void); 25 26blockOfVoidReturningVoid globalBlock; 27 28int nTHCopy(blockOfVoidReturningVoid block) { 29 globalBlock = Block_copy(block); 30 return 1; 31} 32 33int main() { 34 35 __block int x = 0; 36 37 x = nTHCopy(^{ 38 // x should be the value returned by nTHCopy 39 if (x != 1) { 40 fail("but it wasn't updated properly!"); 41 } 42 }); 43 44 globalBlock(); 45 if (x == 0) { 46 fail("x here should be 1, but instead is: %d", x); 47 } 48 49 succeed(__FILE__); 50} 51 52