tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks


From: Vincent Lefevre
Subject: Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks
Date: Mon, 11 Jul 2022 18:50:43 +0200
User-agent: Mutt/2.2.6+26 (7d9df177) vl-149028 (2022-07-06)

On 2022-07-11 17:47:31 +0200, Domingo Alvarez Duarte wrote:
> Although gcc compiles a file containing your example with warnings, I'm not
> sure it's worth try to do the same in TiinyCC the preprocessor probably uses
> TOKENS from the lexer to decide to skip till the end of the initial "#if 0"
> and '"' is not a valid token the error probably come from the lexer that
> found a non terminated string.

I agree that tcc should reject the code. It is too ambiguous to be
regarded as an extension. GCC's interpretation is rather ugly.

Consider a file "err.c":

#define FOO bar
"
FOO
"
"FOO"

zira:~> gcc -E err.c 2> /dev/null
# 0 "err.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "err.c"

"
bar
"
"FOO"

while with tcc:

zira:~> tcc -E err.c
# 1 "err.c"
# 1 "<command line>" 1
# 2 "err.c" 2


"
FOO
"
"FOO"

which makes more sense as an extension, IMHO. But tcc doesn't give
any diagnostic there, and I think that this is incorrect.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]