This is an archive of the discontinued LLVM Phabricator instance.

clang-cl: Emit normal narrowing diagnostics for initializer lists if -fmsc-version is at least 1900 (i.e. MSVC2015).
ClosedPublic

Authored by thakis on Jun 18 2018, 1:25 PM.

Details

Reviewers
rnk
Summary

Diagnostics for narrowing conversions in initializer lists are currently DefaultIgnored in Microsoft mode. But MSVC 2015 did add warnings about narrowing conversions (C2397), so clang-cl can remove its special case code if MSCompatibilityVersion is new enough.

(In MSVC, C2397 is just a warning and in clang it's default-mapped to an error, but it can be remapped, and disabled with -Wno-c++11-narrowing, so that should be fine.)

Fixes PR37314.

Diff Detail

Event Timeline

thakis created this revision.Jun 18 2018, 1:25 PM
rnk added a comment.Jun 18 2018, 2:09 PM

Do you think we should go ahead and remove the DefaultIgnore on these warnings as well? At this point, approximately nobody will see them.

clang/lib/Sema/SemaInit.cpp
8380–8381

Can you hoist this out of the switch or put it in a helper, maybe with a name like [Ii]sNarrowingAnError

8390

I'd put the break inside the brace if you still need it after this.

thakis updated this revision to Diff 151844.Jun 18 2018, 8:16 PM
thakis marked 2 inline comments as done.

comments

Thanks! I'd keep it DefaultIgnored: I'd be annoyed if I'd get these by default in C++98 mode.

rnk accepted this revision.Jun 19 2018, 1:21 PM

Thanks! I'd keep it DefaultIgnored: I'd be annoyed if I'd get these by default in C++98 mode.

Got it, for some reason I'd forgotten they show up in C++98. I'd argue that the warnings are valuable, at least for helping people transition to C++11, but that behavior change is a separate discussion.

This revision is now accepted and ready to land.Jun 19 2018, 1:21 PM
thakis closed this revision.Jun 19 2018, 4:24 PM

r335082, thanks!