[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] -Werror=X (but ugly)
From: |
grischka |
Subject: |
Re: [Tinycc-devel] -Werror=X (but ugly) |
Date: |
Wed, 28 Jul 2021 13:12:36 +0200 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Steffen Nurpmeso wrote:
| gcc -Wwrite-strings -Werror=discarded-qualifiers
Hm. Well then this part is not compatible it seems.
Not compatible and cannot work:
const char *xxx = "123"; /* no warning or error here */
foo(); /* nobody said we would want this to stop */
$ tcc -Werror=write-strings ...
test.c:8: error: implicit declaration of function 'foo'
Because -Wwrite-strings is NOT a warning option, really.
And with
const char *xxx = "123";
strcpy(xxx,"456");
tcc would complain the "discarded const qualifier" but it cannot
track variables and code flow at compile-time in order to know
that some pointer came from a string, originally.
Forget it.
I have never
tested it that much, i usually step in when somewhere the build
fails or spits warnings like grazy. Actually i have given up on
managing the mess that happens from compiler development.
Yes, the mess ... eventually it can be reduced:
$ git log -1 --shortstat --oneline eadcee65
eadcee65 macos: yet another tbd adjustment
8 files changed, 155 insertions(+), 169 deletions(-)
14 lines less, same functionality (although Christian claims that
it's broken since, who knows... ;)
Unfortunately tcc_warning() does not take arguments itself ...
I would (maybe) go for
tcc_warning(On_warn_badthing "bad thing did happen with %s", stuff);
with say
#define On_warn_badthing "\005"
While not sooo nice without a comma, it would allow to "manage away"
quite a few existing 'if (s1->warn_...)' clauses already and seems
somewhat easily extensible.
With some luck one might be able to implement the feature (-Werror= etc.)
and come out with +/- zero or even less additional lines required.
Currently it still adds 78 lines total though:
$ git diff --shortstat a7a138~1 2709b7
8 files changed, 126 insertions(+), 48 deletions(-)
--- grischka