This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion
ClosedPublic

Authored by MaskRay on Apr 22 2020, 12:05 PM.

Details

Summary

Currently, both warn_impcast_integer_float_precision_constant and
warn_impcast_integer_float_precision are covered by
-Wimplicit-int-float-conversion, but only the ..._constant warning is on
by default.

warn_impcast_integer_float_precision_constant likely flags real problems
while warn_impcast_integer_float_precision may flag legitimate use
cases (for example, int used with limited range supported by float).

If -Wno-implicit-int-float-conversion is used, currently there is no way
to restore the ..._constant warning. This patch adds
-Wimplicit-const-int-float-conversion to address the issue. (Similar to
the reasoning in https://reviews.llvm.org/D64666#1598194)

Adapted from a patch by Brooks Moses.

Diff Detail

Event Timeline

MaskRay created this revision.Apr 22 2020, 12:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2020, 12:05 PM
MaskRay updated this revision to Diff 259370.Apr 22 2020, 12:54 PM

Fixed a typo noticed by @bmoses

clang/test/Sema/implicit-int-float-conversion.c
3

If I understand the bug description properly:
You should add a test based on the description where you disable -Wimplicit-int-float-conversion, then re-enable -Wimplicit-const-int-float-conversion, and observe -Wimplicit-const-int-float-conversion diagnostics. ie.

// RUN: %clang_cc1 %s -verify -Wno-implicit-int-float-conversion -Wimplicit-const-int-float-conversion
MaskRay updated this revision to Diff 259398.Apr 22 2020, 2:26 PM
MaskRay marked an inline comment as done.

Change RUN lines

MaskRay edited the summary of this revision. (Show Details)Apr 22 2020, 2:27 PM
nickdesaulniers accepted this revision.Apr 22 2020, 3:52 PM

Thanks for the helping get the patch upstreamed!

This revision is now accepted and ready to land.Apr 22 2020, 3:52 PM
This revision was automatically updated to reflect the committed changes.