ltcmelo / psychec

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

`unsigned` modifier on `__INT32_TYPE__ ` unsupported #35

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

llvm.c:0:24 error: expected `,' or `;' or `=' after declarator, got `uint32_t'
unsigned __INT32_TYPE__ uint32_t;
                        ^

(return code 0)

Content of file

unsigned __INT32_TYPE__ uint32_t;

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
aytey commented 3 years ago

I think this "goes away" if you use the preprocessor (see #40):

avj@platypus ~/clones/psychec/preprocessor/build$ cat /tmp/moo/b.c
unsigned __INT32_TYPE__ uint32_t;
avj@platypus ~/clones/psychec/preprocessor/build$ ./cnip /tmp/moo/b.c; echo $?
b.c:0:24 error: expected `,' or `;' or `=' after declarator, got `uint32_t'
unsigned __INT32_TYPE__ uint32_t;
                        ^

0
avj@platypus ~/clones/psychec/preprocessor/build$ ./cnip --cc-pp /tmp/moo/b.c; echo $?
0
ltcmelo commented 2 years ago

Yes, this is a predefined macro. I created a label for this kind of errors as there are probably other and it'll be good to quickly spot them.

ltcmelo commented 2 years ago

Fixed with #62 .