[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / BlocksRuntime / varargs-bad-assign.c
blobb978668b95c061e000ddd1b9078131fcfd4b777a
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 // HACK ALERT: gcc and g++ give different errors, referencing the line number to ensure that it checks for the right error; MUST KEEP IN SYNC WITH THE TEST
9 // CONFIG 27: error:
11 #import <stdio.h>
12 #import <stdlib.h>
13 #import <string.h>
14 #import <stdarg.h>
17 int main (int argc, const char * argv[]) {
18 int (^sumn)(int n, ...);
19 int six = 0;
21 sumn = ^(int a, int b, int n, ...){
22 int result = 0;
23 va_list numbers;
24 int i;
26 va_start(numbers, n);
27 for (i = 0 ; i < n ; i++) {
28 result += va_arg(numbers, int);
30 va_end(numbers);
32 return result;
35 six = sumn(3, 1, 2, 3);
37 if ( six != 6 ) {
38 printf("%s: Expected 6 but got %d\n", argv[0], six);
39 exit(1);
42 printf("%s: success\n", argv[0]);
43 return 0;