llvm-project/clang/test/Sema/implicit-int-float-narrowing.cpp
Ziang Wan 87b668befe [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss
Issue an warning when the code tries to do an implicit int -> float
conversion, where the float type ha a narrower significant than the
float type.

The new warning is controlled by flag -Wimplicit-int-float-conversion,
under -Wimplicit-float-conversion and -Wconversion. It is also silenced
when c++11 narrowing warning is issued.

Differential Revision: https://reviews.llvm.org/D64666

llvm-svn: 367497
2019-08-01 00:16:43 +00:00

11 lines
340 B
C++

// RUN: %clang_cc1 %s -verify -Wno-conversion -Wno-c++11-narrowing -Wimplicit-int-float-conversion
void testNoWarningOnNarrowing() {
// Test that we do not issue duplicated warnings for
// C++11 narrowing.
float a = {222222222222L}; // expected-no-diagnostics
long b = 222222222222L;
float c = {b}; // expected-no-diagnostics
}