ltcmelo / psychec

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

Function returning function pointer unsupported #36

Closed aytey closed 3 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

tiny.c:0:23 error: expected `,' or `;' or `=' after declarator, got `{'
void(*foo(void))(void) { return 0; }
                       ^
tiny.c:0:35 warning: missing type specifier, assume `int'
void(*foo(void))(void) { return 0; }
                                   ^
tiny.c:0:35 error: expected <identifier> or `(' starting direct-declarator, got `}'
void(*foo(void))(void) { return 0; }
                                   ^

(return code 0)

Content of file

void(*foo(void))(void) { return 0; }

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

Thanks @andrewvaughanj . (This issue happens only for function definitions.)

ltcmelo commented 3 years ago

Fixed with https://github.com/ltcmelo/psychec/commit/214eabdc233aa62fd4e7d203e5fab99efa4d2cb6