Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / BlocksRuntime / globalexpression.c
blob759a9d29b6d685c33b2cc1aef03ba1f728d9fffb
1 //
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 // testfilerunner CONFIG
8 #import <stdio.h>
9 #import <Block.h>
11 int global;
13 void (^gblock)(int) = ^(int x){ global = x; };
15 int main(int argc, char *argv[]) {
16 gblock(1);
17 if (global != 1) {
18 printf("%s: *** did not set global to 1\n", argv[0]);
19 return 1;
21 void (^gblockcopy)(int) = Block_copy(gblock);
22 if (gblockcopy != gblock) {
23 printf("global copy %p not a no-op %p\n", (void *)gblockcopy, (void *)gblock);
24 return 1;
26 Block_release(gblockcopy);
27 gblock(3);
28 if (global != 3) {
29 printf("%s: *** did not set global to 3\n", argv[0]);
30 return 1;
32 gblockcopy = Block_copy(gblock);
33 gblockcopy(5);
34 if (global != 5) {
35 printf("%s: *** did not set global to 5\n", argv[0]);
36 return 1;
38 printf("%s: Success!\n", argv[0]);
39 return 0;