diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
commit | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch) | |
tree | 02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /test/SemaCXX/warn-float-conversion.cpp | |
parent | c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff) |
Diffstat (limited to 'test/SemaCXX/warn-float-conversion.cpp')
-rw-r--r-- | test/SemaCXX/warn-float-conversion.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-float-conversion.cpp b/test/SemaCXX/warn-float-conversion.cpp index a3d178622c7d7..7dec4844b062e 100644 --- a/test/SemaCXX/warn-float-conversion.cpp +++ b/test/SemaCXX/warn-float-conversion.cpp @@ -41,6 +41,32 @@ void Convert(float f, double d, long double ld) { l = ld; //expected-warning{{conversion}} } +void CompoundAssignment() { + int x = 3; + + x += 1.234; //expected-warning{{conversion}} + x -= -0.0; //expected-warning{{conversion}} + x *= 1.1f; //expected-warning{{conversion}} + x /= -2.2f; //expected-warning{{conversion}} + + int y = x += 1.4f; //expected-warning{{conversion}} + + float z = 1.1f; + double w = -2.2; + + y += z + w; //expected-warning{{conversion}} +} + +# 1 "foo.h" 3 +// ^ the following text comes from a system header file. +#define SYSTEM_MACRO_FLOAT(x) do { (x) += 1.1; } while(0) +# 1 "warn-float-conversion.cpp" 1 +// ^ start of a new file. +void SystemMacro() { + float x = 0.0f; + SYSTEM_MACRO_FLOAT(x); +} + void Test() { int a1 = 10.0/2.0; //expected-warning{{conversion}} int a2 = 1.0/2.0; //expected-warning{{conversion}} |