ltcmelo / psychec

A compiler frontend for the C programming language
BSD 3-Clause "New" or "Revised" License
536 stars 39 forks source link

__builtin_va_arg variadic arguments unsupported #33

Closed aytey closed 2 years ago

aytey commented 3 years ago

GCC version:

gcc (SUSE Linux) 10.2.1 20201202 [revision e563687cf9d3d1278f45aaebd03e0f66531076c9]

clang version:

clang version 11.0.1

Output of gcc -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME

(return code 0)

Output of clang -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME

(return code 0)

Output of cnip $FNAME

varargs.c:0:57 error: expected expression got `long'
long a(__builtin_va_list b) { return __builtin_va_arg(b, long); }
                                                         ^

(return code 0)

Content of file

long a(__builtin_va_list b) { return __builtin_va_arg(b, long); }

psychec version

commit d10dc1ddfb7ea845f59274a4d6ca5d021ab31423
Author: Leandro T. C. Melo <LTCMELO@GMAIL.COM>
Date:   Tue Mar 9 21:18:30 2021 -0300

    fix postfixing on compound literal
ltcmelo commented 3 years ago

The reason for this error is that __builtin_va_arg the va_arg macro (builtin) implementation, but Psyche-C is parsing it as a regular function which, in turn, can't accept a type (i.e., long) as value argument. I'll implementing handling for those builtins.

ltcmelo commented 2 years ago

Fixed with https://github.com/ltcmelo/psychec/pull/64.