[PATCH] D58154: Add support for -fpermissive.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 12:47:27 PST 2019


rsmith added a comment.

In D58154#1419956 <https://reviews.llvm.org/D58154#1419956>, @jyknight wrote:

> I also can't really tell what the intent is behind classifying some diagnostics in Clang as ExtWarn,DefaultError and others Warning,DefaultError -- or if there even is any useful purpose there at all. I note with special-puzzlement the existence of both `ext_return_missing_expr` and `warn_return_missing_expr`.


`ExtWarn,DefaultError` is for extensions that we disable by default. It should only ever fire on non-conforming code. Such extensions are implicitly enabled in system headers and can be explicitly enabled with a `-Wno-` flag.

`Warning,DefaultError` is for conforming code that we can accept, but that's doing something so egregious that we choose to reject it by default. Such cases should be incredibly rare. As above, such cases are permitted in system headers and the error can be downgraded via a -W flag.

`ext_return_missing_expr` is used in languages where a `return` statement with no expression is ill-formed (everything later than C90), and `warn_return_missing_expr` is used in the case where it's valid but is very likely to result in undefined behavior (C90). (This patch certainly has surprising behavior for these diagnostics -- demoting the former case to a warning but leaving the latter as an error -- which I think strongly suggests that this is the wrong approach for `-fpermissive`.)

> I guess my feeling now is that perhaps we should just eliminate that categorization as meaningless, and just make -Wno-error=everything work properly (for anyone who wants to not abort the compile on broken code, but for whatever reason also loves to see build-spam so doesn't want -Wno-everything).

The existing categories seem meaningful to me. I agree that making `-Wno-error=everything` work would probably be a good idea.

I don't have particularly strong feelings one way or the other about accepting `-fpermissive` at all. For GCC compatibility, it seems like a moderately useful thing to support, but I don't think we have any interest in accepting everything that GCC accepts under `-fpermissive`. Perhaps the better choice is to not provide the flag at all, rather than to provide something that has the same interface but doesn't accept the same code. If not that, making `-fpermissive` an alias for `-Wno-error=everything` is probably a better approach than that of this patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58154





More information about the cfe-commits mailing list