diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/coroutines.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-float-conversion.cpp | 6 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-literal-conversion.cpp | 7 |
3 files changed, 11 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp index 2c979f5b30d..0d0588dbbf0 100644 --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -157,7 +157,7 @@ struct coroutine_handle<void> { void yield() { co_yield 0; co_yield {"foo", 1, 2}; - co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}} + co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}} co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} co_yield {"foo"}; co_yield "foo"; // expected-error {{no matching}} diff --git a/clang/test/SemaCXX/warn-float-conversion.cpp b/clang/test/SemaCXX/warn-float-conversion.cpp index fc221893aee..cf1ead038f3 100644 --- a/clang/test/SemaCXX/warn-float-conversion.cpp +++ b/clang/test/SemaCXX/warn-float-conversion.cpp @@ -81,9 +81,9 @@ void TestOverflow() { char b = -500.0; // caught by -Wliteral-conversion const float LargeNumber = 1024; - char c = LargeNumber; // expected-warning{{implicit conversion of out of range value from 'const float' to 'char' changes value from 1024 to 127}} - char d = 400.0 + 400.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'char' changes value from 800 to 127}} + char c = LargeNumber; // expected-warning{{implicit conversion of out of range value from 'const float' to 'char' is undefined}} + char d = 400.0 + 400.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'char' is undefined}} - char e = 1.0 / 0.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'char' changes value from +Inf to 127}} + char e = 1.0 / 0.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'char' is undefined}} } #endif // OVERFLOW diff --git a/clang/test/SemaCXX/warn-literal-conversion.cpp b/clang/test/SemaCXX/warn-literal-conversion.cpp index 875aa1dec5e..7efcf90fd96 100644 --- a/clang/test/SemaCXX/warn-literal-conversion.cpp +++ b/clang/test/SemaCXX/warn-literal-conversion.cpp @@ -48,4 +48,11 @@ void test1() { // values. bool b3 = 0.0f; bool b4 = 0.0; + + // These all warn because they overflow the target type. + short s = 32768.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'short' is undefined}} + unsigned short us = 65536.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'unsigned short' is undefined}} + + short s2 = -32769.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'short' is undefined}} + unsigned short us2 = -65537.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'unsigned short' is undefined}} } |

