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