[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 30 10:17:12 PDT 2022


aaron.ballman added a comment.

In D122983#3484064 <https://reviews.llvm.org/D122983#3484064>, @manojgupta wrote:

> We are finding a lot of failures in our ToT builds with this change. here is an example for a configure script:
>
> $ cat tent.c
> int  main ()
> {
>  tgetent(0,0);
>  return 0;
> }
> $ bin/clang -c tent.c -Wno-error
> tent.c:3:2: error: call to undeclared function 'tgetent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>  tgetent(0,0);
>  ^
> 1 error generated.
>
> It feels very surprising that Wno-error does not suppress this warning. Is that expected?

Yes and no. Warnings which default to an error have very surprising behavior (at least to me) in terms of `-Werror` and `-w`. Specifying `-Wno-error` doesn't downgrade these diagnostics into a warning (https://godbolt.org/z/c43zTqTj1) and specifying `-w` doesn't disable the warning (https://godbolt.org/z/Y8YYYecTd). As you can see, that behavior is not specific to this patch but is just a general behavior with these kinds of diagnostics. I also find the behavior surprising (in both cases), but the last time I asked around about it, it sounded like this behavior was intentional for some reasons. More exploration is needed to know whether we should make any changes there.

In the meantime, `-Wno-error=implicit-function-declaration` should downgrade the error to a warning for you (but as you noticed, you can't later re-upgrade it into an error; so yes, these things behave a bit strangely IMO).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122983/new/

https://reviews.llvm.org/D122983



More information about the cfe-commits mailing list