Closed aytey closed 3 years ago
Same for true
:
gcc (SUSE Linux) 10.2.1 20201202 [revision e563687cf9d3d1278f45aaebd03e0f66531076c9]
clang version 11.0.1
gcc -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME
(return code 0)
clang -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME
(return code 0)
cnip $FNAME
bool.c:0:4 error: expected <identifier> or `(' starting direct-declarator, got `true'
int true;
^
(return code 0)
int true;
psychec
versioncommit d10dc1ddfb7ea845f59274a4d6ca5d021ab31423
Author: Leandro T. C. Melo <LTCMELO@GMAIL.COM>
Date: Tue Mar 9 21:18:30 2021 -0300
fix postfixing on compound literal
Thanks @andrewvaughanj , I see that you created a good batch of new issues :wink:.
This behavior is expected: cnip invokes psyche-c's parser with the default language extensions options, which, in turn, consider true a keyword (false as well).
Perhaps I should consider changing this specific default then, to keep consistency with GCC/clang… and diagnose an issue only in semantic analysis, it would be with the inclusion of header <stdbool.h>
.
Looking at GCC, if you use <stdbool.h>
then true
/false
get expanded like this:
#define bool _Bool
#define true 1
#define false 0
Could cnip
not have true
and false
as built-ins, and get these in the same way via the the #defines
? You'd need to treat _Bool
as a built-in, of course.
But I don't know enough as to why cnip
needs to consider true
and false
as "built-ins".
I don't know enough as to why cnip needs to consider true and false as "built-ins".
It doesn't need to… those just happen to be the defaults; I'll adjust them.
However, I can't rely on the #defines
during syntax analysis only, so the content of <stdbool.h>
will only take effect after semantic analysis (which I haven't yet finished int he master branch) — or if the according language extensions are explicitly enabled (after I adjust the defaults).
GCC version:
clang version:
Output of
gcc -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME
Output of
clang -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME
Output of
cnip $FNAME
Content of file
psychec
version