[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / BlocksRuntime / small-struct.c
blob434f3c179f7ef39afd390f31c6ab03f6ae1dbe98
1 //
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.
7 // -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil; -*-
8 // CONFIG
10 #import <stdio.h>
11 #import <stdlib.h>
12 #import <string.h>
14 typedef struct {
15 int a;
16 int b;
17 } MiniStruct;
19 int main (int argc, const char * argv[]) {
20 MiniStruct inny;
21 MiniStruct outty;
22 MiniStruct (^copyStruct)(MiniStruct);
24 memset(&inny, 0xA5, sizeof(inny));
25 memset(&outty, 0x2A, sizeof(outty));
27 inny.a = 12;
28 inny.b = 42;
30 copyStruct = ^(MiniStruct aTinyStruct){ return aTinyStruct; }; // pass-by-value intrinsically copies the argument
32 outty = copyStruct(inny);
34 if ( &inny == &outty ) {
35 printf("%s: struct wasn't copied.", argv[0]);
36 exit(1);
38 if ( (inny.a != outty.a) || (inny.b != outty.b) ) {
39 printf("%s: struct contents did not match.", argv[0]);
40 exit(1);
43 printf("%s: success\n", argv[0]);
44 return 0;