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.
6
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:
10
11#import <stdio.h>
12#import <stdlib.h>
13#import <string.h>
14#import <stdarg.h>
15
16
17int main (int argc, const char * argv[]) {
18    int (^sumn)(int n, ...);
19    int six = 0;
20
21    sumn = ^(int a, int b, int n, ...){
22        int result = 0;
23        va_list numbers;
24        int i;
25
26        va_start(numbers, n);
27        for (i = 0 ; i < n ; i++) {
28            result += va_arg(numbers, int);
29        }
30        va_end(numbers);
31
32        return result;
33    };
34
35    six = sumn(3, 1, 2, 3);
36
37    if ( six != 6 ) {
38        printf("%s: Expected 6 but got %d\n", argv[0], six);
39        exit(1);
40    }
41
42    printf("%s: success\n", argv[0]);
43    return 0;
44}
45