Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
cmake
docs
include
lib
test
BlocksRuntime
block-static.c
blockimport.c
byrefaccess.c
byrefcopy.c
byrefcopycopy.c
byrefcopyinner.c
byrefcopyint.c
byrefcopystack.c
byrefsanity.c
byrefstruct.c
c99.c
cast.c
constassign.c
copy-block-literal-rdar6439600.c
copyconstructor.C
copynull.c
dispatch_async.c
dispatch_call_Block_with_release.c
fail.c
flagsisa.c
globalexpression.c
goto.c
hasdescriptor.c
josh.C
k-and-r.c
large-struct.c
localisglobal.c
macro.c
makefile
modglobal.c
nestedimport.c
nullblockisa.c
objectRRGC.c
objectassign.c
orbars.c
rdar6396238.c
rdar6405500.c
rdar6414583.c
recursive-block.c
recursive-test.c
recursiveassign.c
reference.C
rettypepromotion.c
returnfunctionptr.c
shorthandexpression.c
sizeof.c
small-struct.c
structmember.c
testfilerunner.h
testfilerunner.m
varargs-bad-assign.c
varargs.c
variadic.c
voidarg.c
asan
builtins
cfi
dfsan
esan
fuzzer
hwasan
interception
lsan
msan
profile
safestack
sanitizer_common
scudo
tsan
ubsan
ubsan_minimal
xray
CMakeLists.txt
lit.common.cfg
lit.common.configured.in
unittests
www
.arcconfig
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/compiler-rt/test/BlocksRuntime/recursive-block.c
Xamarin Public Jenkins (auto-signing) 468663ddbb Imported Upstream version 6.10.0.49
Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
2020-01-16 16:38:04 +00:00

56 lines
1.1 KiB
C

//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <stdio.h>
#include <Block.h>
#include <Block_private.h>
#include <stdlib.h>
// CONFIG
int cumulation = 0;
int doSomething(int i) {
cumulation += i;
return cumulation;
}
void dirtyStack() {
int i = random();
int j = doSomething(i);
int k = doSomething(j);
doSomething(i + j + k);
}
typedef void (^voidVoid)(void);
voidVoid testFunction() {
int i = random();
__block voidVoid inner = ^{ doSomething(i); };
//printf("inner, on stack, is %p\n", (void*)inner);
/*__block*/ voidVoid outer = ^{
//printf("will call inner block %p\n", (void *)inner);
inner();
};
//printf("outer looks like: %s\n", _Block_dump(outer));
voidVoid result = Block_copy(outer);
//Block_release(inner);
return result;
}
int main(int argc, char **argv) {
voidVoid block = testFunction();
dirtyStack();
block();
Block_release(block);
printf("%s: success\n", argv[0]);
return 0;
}