// S : tags min c vararg $TAGS // S : expect --result valid // S : cc -o test.bc $CC_OPT $file // S : verify $V_OPT test.bc #include #include int sum( int count, ... ) { int acc = 0; va_list args; va_start( args, count ); for ( int i = 0; i != count; i++ ) { int x = va_arg( args, int ); acc += x; } va_end( args ); return acc; } int main() { assert( sum( 0 ) == 0 ); assert( sum( 1, 1 ) == 1 ); assert( sum( 2, 1, 2 ) == 3 ); assert( sum( 3, 1, 2, 3 ) == 6 ); }