www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22307] New: importC: unable to parse __builtin_va_arg

https://issues.dlang.org/show_bug.cgi?id=22307

          Issue ID: 22307
           Summary: importC: unable to parse __builtin_va_arg
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

Consider the following preprocessed program using varargs.

typedef __builtin_va_list va_list;
int add_nums(int count, ...)
{
    int result = 0;
    va_list args;
    __builtin_va_start(args, count);
    for (int i = 0; i < count; ++i) {
        result += __builtin_va_arg(args, int); // Error: expression expected,
not `int`
    }
    __builtin_va_end(args);
    return result;
}

__builtin_va_arg is unusual, looking like a function, but taking a type as the
second argument.

--
Sep 14