Re: [Tinycc-devel] -Werror=X (but ugly)
N'morning. grischka wrote in <6105b650.90...@gmx.de>: |Steffen Nurpmeso wrote: |> grischka wrote in |> <6102f8d1.40...@gmx.de>: |>|Steffen Nurpmeso wrote: |>|> The enum adds quite a bit on top of it; the addition of |>|> set_W_flag() is, hmm, not nice, but i hope the current approach is |>|> not too heavy. |>| |>|Maybe not heavy really but unnecessary, in quite some aspects. |>|One of them that after all tinycc currently does have only |>|2 warnings where all that bit-mask fuzz can develop. |>| |>|Just in case, below the commands how you can revert this more |>|or less cleanly: |>| |>|$ git revert -n 2709b7 49cd6f 0d59ac 0c1676 a7a138 |>|$ git commit -m "revert experimental -W[no-]error=X ..." |>| |>|Take care ... |> |> \o/ |> Greetings to the Microsoft world! | |Greetings from the blatant uncomplexers Well hmm that is debatable. |https://repo.or.cz/tinycc.git/commitdiff/4b2c6cf3 But that not, if course. Nice that someone who knows the generator agrees it is doable like that. Ciao. --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
Christian JULLIEN wrote: On macOS M1 (not yet fixed with long double), the latest commit stalls on test 60 ...60_errors_and_warnings ;; runs forever Should work now. I did set the TCC_USING_DOUBLE_FOR_LDOUBLE for macho-arm64 instead which might or might not have some effect. Thanks, --- grischka ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
Same issue with Linux arm (RPi) Le :01 août 2021 à 10:54 (GMT +02:00) De :"Christian JULLIEN" eli...@orange.fr À :"tinycc-devel@nongnu.org" tinycc-devel@nongnu.org Objet :Re: [Tinycc-devel] -Werror=X (but ugly) On macOS M1 (not yet fixed with long double), the latest commit stalls on test 60 ...60_errors_and_warnings ;; runs forever Le :31 juillet 2021 à 22:45 (GMT +02:00) De :"grischka" gris...@gmx.de À :"tinycc-devel@nongnu.org" tinycc-devel@nongnu.org Objet :Re: [Tinycc-devel] -Werror=X (but ugly) Steffen Nurpmeso wrote: grischka wrote in 6102f8d1.40...@gmx.de: |Steffen Nurpmeso wrote: | The enum adds quite a bit on top of it; the addition of | set_W_flag() is, hmm, not nice, but i hope the current approach is | not too heavy. | |Maybe not heavy really but unnecessary, in quite some aspects. |One of them that after all tinycc currently does have only |2 warnings where all that bit-mask fuzz can develop. | |Just in case, below the commands how you can revert this more |or less cleanly: | |$ git revert -n 2709b7 49cd6f 0d59ac 0c1676 a7a138 |$ git commit -m "revert experimental -W[no-]error=X ..." | |Take care ... \o/ Greetings to the Microsoft world! Greetings from the blatant uncomplexers https://repo.or.cz/tinycc.git/commitdiff/4b2c6cf3 -- gr --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
On macOS M1 (not yet fixed with long double), the latest commit stalls on test 60 ...60_errors_and_warnings ;; runs forever Le :31 juillet 2021 à 22:45 (GMT +02:00) De :"grischka" gris...@gmx.de À :"tinycc-devel@nongnu.org" tinycc-devel@nongnu.org Objet :Re: [Tinycc-devel] -Werror=X (but ugly) Steffen Nurpmeso wrote: grischka wrote in 6102f8d1.40...@gmx.de: |Steffen Nurpmeso wrote: | The enum adds quite a bit on top of it; the addition of | set_W_flag() is, hmm, not nice, but i hope the current approach is | not too heavy. | |Maybe not heavy really but unnecessary, in quite some aspects. |One of them that after all tinycc currently does have only |2 warnings where all that bit-mask fuzz can develop. | |Just in case, below the commands how you can revert this more |or less cleanly: | |$ git revert -n 2709b7 49cd6f 0d59ac 0c1676 a7a138 |$ git commit -m "revert experimental -W[no-]error=X ..." | |Take care ... \o/ Greetings to the Microsoft world! Greetings from the blatant uncomplexers https://repo.or.cz/tinycc.git/commitdiff/4b2c6cf3 -- gr --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
Steffen Nurpmeso wrote: grischka wrote in <6102f8d1.40...@gmx.de>: |Steffen Nurpmeso wrote: |> The enum adds quite a bit on top of it; the addition of |> set_W_flag() is, hmm, not nice, but i hope the current approach is |> not too heavy. | |Maybe not heavy really but unnecessary, in quite some aspects. |One of them that after all tinycc currently does have only |2 warnings where all that bit-mask fuzz can develop. | |Just in case, below the commands how you can revert this more |or less cleanly: | |$ git revert -n 2709b7 49cd6f 0d59ac 0c1676 a7a138 |$ git commit -m "revert experimental -W[no-]error=X ..." | |Take care ... \o/ Greetings to the Microsoft world! Greetings from the blatant uncomplexers https://repo.or.cz/tinycc.git/commitdiff/4b2c6cf3 -- gr --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
grischka wrote in <6102f8d1.40...@gmx.de>: |Steffen Nurpmeso wrote: |> The enum adds quite a bit on top of it; the addition of |> set_W_flag() is, hmm, not nice, but i hope the current approach is |> not too heavy. | |Maybe not heavy really but unnecessary, in quite some aspects. |One of them that after all tinycc currently does have only |2 warnings where all that bit-mask fuzz can develop. | |Just in case, below the commands how you can revert this more |or less cleanly: | |$ git revert -n 2709b7 49cd6f 0d59ac 0c1676 a7a138 |$ git commit -m "revert experimental -W[no-]error=X ..." | |Take care ... \o/ Greetings to the Microsoft world! --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
Steffen Nurpmeso wrote: The enum adds quite a bit on top of it; the addition of set_W_flag() is, hmm, not nice, but i hope the current approach is not too heavy. Maybe not heavy really but unnecessary, in quite some aspects. One of them that after all tinycc currently does have only 2 warnings where all that bit-mask fuzz can develop. Just in case, below the commands how you can revert this more or less cleanly: $ git revert -n 2709b7 49cd6f 0d59ac 0c1676 a7a138 $ git commit -m "revert experimental -W[no-]error=X ..." Take care ... --- grischka Keep on going tcc :) Ciao, --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
Hello. grischka wrote in <61013ba4.4000...@gmx.de>: |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 a hard time parsing that, there already is -Wwrite-strings and -Werror=write-strings just propagates the according bit to make it an error state? That is all i know. For me the -Werror thing is done for now, sorry for the necessary fixups, i am a bit chaotic, for public shared repos i should just let things rest for a few days and when it is still ok, then push. In order to be better than what is now in -- what is missing is that "-Werror -Wno-error=write-strings" does not error out for any write-strings error, i.e., that specific errors can be disabled -- i had to wrap my head around the control flow of the code generator, because for write-strings (all others would work out), it just sets a VT_CONSTANT bit or so, then the generator continues over several levels, then some *_cast_* function actually emits a tcc_warning() (i could not figure out when the *_cast_* function that actually emits the write-strings is actually called, from looking say ten minutes). I thought about "quick and dirties": - Just call tcc_warning() directly: would result in two log messages unless the first would error out. I could rename NEED_WARNING() to WANT_WARNING() and add a WANT_ERROR(), and call tcc_warning() only then, in order to error out. - Add some field and another VT_ bit to indicate that field is set, in order to pick it up later. Then there could be another tcc_warn_or_err() which takes the actual "enum warn_option" as its first argument. I actually had this implementation fully implemented yesterday, with error1() still backing all of the warn functions, but for the write-strings case in the generator. - Add a bit like WARN_IGNORE_ERR_NEXT, set this from within NEED_WARNING() when a specific error is disabled but the warning as such shall occur. Then clear that bit again in tcc_warning() (aka error1()). I was thinking of this, and it also would work everywhere, but i did not know whether it will work out for the code generator and the write-strings thing. Because _if_ another error occurs in the generator _before_ we actually call tcc_warning(), then of course a hard error could be falsely ignored. |> 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. Linux syslog thing is also an idea, but not for code generator :) |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(-) The enum adds quite a bit on top of it; the addition of set_W_flag() is, hmm, not nice, but i hope the current approach is not too heavy. Keep on going tcc :) Ciao, --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
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 ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
grischka wrote in <60ff3c86.6020...@gmx.de>: |Steffen Nurpmeso wrote: ... |> I would like to have it, but the implementation is so ugly! | |Classic dilemma ... Oooh .. yes. ... |> Also, things like write-strings play with | |What "things like write-strings"? There is only -Wwrite-strings |which is different. Also in gcc, to stop it needs | | gcc -Wwrite-strings -Werror=discarded-qualifiers Hm. Well then this part is not compatible it seems. 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. |> conditions and states which later result in "something", so having |> a global this_is_the_actual_warning_trigger would need to be |> looked at in error1(), and the "is not warning but error" state be |> deduced there only; yet, this was too complicated. | |Ok, could be done all in only one place but is too complicated... (?!?) I had instrumented the code this afternoon, but the code generator would require real brain effort. The flag is set, but when actually the warning occurs, i dunno, it is much, much later. I thought about adding a specific function, you know, like warnopt() or so, that could check for -Werror -Wno-error=X not bailing for X, it is really only these places in the generator which make it weird. Unfortunately tcc_warning() does not take arguments itself, even though variable preprocessor arguments where pretty much widespread already over twenty years ago .. with different syntax. I also never used it. It did X((Y)), this could be a solution here too. It still does not help for the generator, sadly. |> The below thus works | |(partially sometimes) | |> but is far from what i had in mind, which is |> why i refrained from committing it (which i never tried in years |> also, who still knows how that works)? | |> What do you think? | |What we do think about what is far from what you did think? ;) Despite that being too complicated ... ... i have to cook! Ciao, --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] -Werror=X (but ugly)
Steffen Nurpmeso wrote: Hello! I would like to have it, but the implementation is so ugly! Classic dilemma ... My "natural" thought would be to have flag carriers, and simply use bit 1 for "warn" and bit 2 for "error out", but that needs quite some work. Sure. Natural and simple idea but too much work. Also, things like write-strings play with What "things like write-strings"? There is only -Wwrite-strings which is different. Also in gcc, to stop it needs gcc -Wwrite-strings -Werror=discarded-qualifiers conditions and states which later result in "something", so having a global this_is_the_actual_warning_trigger would need to be looked at in error1(), and the "is not warning but error" state be deduced there only; yet, this was too complicated. Ok, could be done all in only one place but is too complicated... (?!?) The below thus works (partially sometimes) but is far from what i had in mind, which is why i refrained from committing it (which i never tried in years also, who still knows how that works)? What do you think? What we do think about what is far from what you did think? ;) -- gr From: Steffen Nurpmeso Date: Mon, 26 Jul 2021 16:18:45 +0200 Subject: [PATCH] (Complicated,ugly) -Werror=(need unrolled code) support --- libtcc.c | 24 +++- tcc.h| 2 ++ tccgen.c | 15 --- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/libtcc.c b/libtcc.c index 2002dd56c9..eb38f339a4 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1647,6 +1647,14 @@ static const FlagDef options_W[] = { { 0, 0, NULL } }; +/* XXX ideally .warn* would be flags, 1=only warn, 2=warn and out? */ +static const FlagDef options_Werror[] = { +{ offsetof(TCCState, warn_write_strings_error), WD_ALL, "write-strings" }, +{ offsetof(TCCState, warn_implicit_function_declaration_error), WD_ALL, + "implicit-function-declaration" }, +{ 0, 0, NULL } +}; + static const FlagDef options_f[] = { { offsetof(TCCState, char_is_unsigned), 0, "unsigned-char" }, { offsetof(TCCState, char_is_unsigned), FD_INVERT, "signed-char" }, @@ -1938,8 +1946,22 @@ reparse: break; case TCC_OPTION_W: s->warn_none = 0; -if (optarg[0] && set_flag(s, options_W, optarg) < 0) +if (optarg[0] && set_flag(s, options_W, optarg) < 0) { +char *sub; +int subt = 0; + +/* XXX -W[no-]error= handling ugly; -W+: enum,flag carrier? */ +if ((sub = strchr(optarg, '=')) != NULL && +(!strncmp(optarg, "error", (uintptr_t)(sub-optarg)) || + (subt = 1, !strncmp(optarg, "no-error", +(uintptr_t)(sub - optarg && +set_flag(s, options_Werror, ++sub) == 0) { +if (subt != 1) +set_flag(s, options_W, sub); +break; +} goto unsupported_option; +} break; case TCC_OPTION_w: s->warn_none = 1; diff --git a/tcc.h b/tcc.h index cc8a2f82b5..3bb75215e9 100644 --- a/tcc.h +++ b/tcc.h @@ -775,10 +775,12 @@ struct TCCState { /* warning switches */ unsigned char warn_write_strings; +unsigned char warn_write_strings_error; unsigned char warn_unsupported; unsigned char warn_error; unsigned char warn_none; unsigned char warn_implicit_function_declaration; +unsigned char warn_implicit_function_declaration_error; unsigned char warn_gcc_compat; /* compile with debug symbol (and use them if error during execution) */ diff --git a/tccgen.c b/tccgen.c index 833b70431a..4fd30476a4 100644 --- a/tccgen.c +++ b/tccgen.c @@ -5915,8 +5915,11 @@ ST_FUNC void unary(void) len = strlen(funcname) + 1; /* generate char[len] type */ type.t = VT_BYTE; -if (tcc_state->warn_write_strings) +if (tcc_state->warn_write_strings) { +if (tcc_state->warn_write_strings_error) +tcc_state->warn_error = 1; type.t |= VT_CONSTANT; +} mk_pointer(); type.t |= VT_ARRAY; type.ref->c = len; @@ -5942,8 +5945,11 @@ ST_FUNC void unary(void) if (tcc_state->char_is_unsigned) t = VT_BYTE | VT_UNSIGNED; str_init: -if (tcc_state->warn_write_strings) +if (tcc_state->warn_write_strings) { +if (tcc_state->warn_write_strings_error) +tcc_state->warn_error = 1; t |= VT_CONSTANT; +} type.t = t; mk_pointer(); type.t |= VT_ARRAY; @@ -6384,8 +6390,11 @@ special_math_val: (which usually start with uppercase letter) */ || (name[0] >= 'A' && name[0] <= 'Z') #endif -) +) { +if
Re: [Tinycc-devel] -Werror=X (but ugly)
Steffen Nurpmeso wrote in <20210726142524.soil2%stef...@sdaoden.eu>: |+ (subt = 1, !strncmp(optarg, "no-error", |+(uintptr_t)(sub - optarg && |+set_flag(s, options_Werror, ++sub) == 0) { Ah merde, of course this is also broken as we need to carry the "no-" along down to set_flag. That i would fix before committing this what i do not like. --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel