1/*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LLVM_LICENSE_HEADER@
5 */
6
7//  -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil;  -*-
8// TEST_CONFIG
9
10#import <stdio.h>
11#import <stdlib.h>
12#import <string.h>
13#import "test.h"
14
15typedef struct {
16  int a;
17  int b;
18} MiniStruct;
19
20int main () {
21    MiniStruct inny;
22    MiniStruct outty;
23    MiniStruct (^copyStruct)(MiniStruct);
24
25    memset(&inny, 0xA5, sizeof(inny));
26    memset(&outty, 0x2A, sizeof(outty));
27
28    inny.a = 12;
29    inny.b = 42;
30
31    copyStruct = ^(MiniStruct aTinyStruct){ return aTinyStruct; };  // pass-by-value intrinsically copies the argument
32
33    outty = copyStruct(inny);
34
35    if ( &inny == &outty ) {
36        fail("struct wasn't copied");
37    }
38    if ( (inny.a != outty.a) || (inny.b != outty.b) ) {
39        fail("struct contents did not match");
40    }
41
42    succeed(__FILE__);
43}
44