[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 11:47:49 PDT 2019


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D58896#1428816 <https://reviews.llvm.org/D58896#1428816>, @edward-jones wrote:

> In D58896#1419964 <https://reviews.llvm.org/D58896#1419964>, @aaron.ballman wrote:
>
> > Do you have some evidence that the current behavior is causing a lot of false positives in the wild? For ASCII character literals, I can sort of guess at why people might want to do this, but for things like wide character literals, or character literals relying on the current code page, etc, I'm less convinced.
>
>
> I don't know about the false positive rate,  just the one report on twitter which triggered me to submit this change. As for wide character literals I was under the impression that they would be promoted to integers and wouldn't have triggered the -Wchar-subscript anyway?


Ordinary character literals are promoted as well, aren't they? `'a'` has type `char`, and that should promote up to `int`. My point was that you are silencing the warning on any character literal, not just ordinary character literals. However, I see now that `-Wchar-subscript` is very serious about `char`, rather than any character type, so I guess you don't need to distinguish between character literal kinds because the type system already deals with that for you.

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D58896





More information about the cfe-commits mailing list