blob: c451d3f348c93928516b240a19980ce54446e23b [file] [log] [blame]
Blaine Garst86d0ba42010-08-04 23:34:21 +00001//
2// The LLVM Compiler Infrastructure
3//
4// This file is distributed under the University of Illinois Open Source
5// License. See LICENSE.TXT for details.
6
7/*
8 * structmember.c
9 * testObjects
10 *
11 * Created by Blaine Garst on 9/30/08.
12 * CONFIG
13 */
14#include <Block.h>
15#include <Block_private.h>
16#include <stdio.h>
17
18// CONFIG
19
20int main(int argc, char *argv[]) {
21 struct stuff {
22 long int a;
23 long int b;
24 long int c;
25 } localStuff = { 10, 20, 30 };
26 int d;
27
28 void (^a)(void) = ^ { printf("d is %d", d); };
29 void (^b)(void) = ^ { printf("d is %d, localStuff.a is %lu", d, localStuff.a); };
30
31 unsigned nominalsize = Block_size(b) - Block_size(a);
32#if __cplusplus__
33 // need copy+dispose helper for C++ structures
34 nominalsize += 2*sizeof(void*);
35#endif
36 if ((Block_size(b) - Block_size(a)) != nominalsize) {
37 printf("sizeof a is %ld, sizeof b is %ld, expected %d\n", Block_size(a), Block_size(b), nominalsize);
38 printf("dump of b is %s\n", _Block_dump(b));
39 return 1;
40 }
41 printf("%s: Success\n", argv[0]);
42 return 0;
43}
44
45