diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /test/SemaCXX/warn-sign-conversion-cpp11.cpp | |
parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) |
Diffstat (limited to 'test/SemaCXX/warn-sign-conversion-cpp11.cpp')
-rw-r--r-- | test/SemaCXX/warn-sign-conversion-cpp11.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-sign-conversion-cpp11.cpp b/test/SemaCXX/warn-sign-conversion-cpp11.cpp new file mode 100644 index 0000000000000..e18b7f5645432 --- /dev/null +++ b/test/SemaCXX/warn-sign-conversion-cpp11.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s + +unsigned int test() { + short foo; + return foo; // expected-warning {{implicit conversion changes signedness}} + +} + +unsigned int test3() { + // For a non-defined enum, use the underlying type. + enum u8 : signed char; + u8 foo{static_cast<u8>(0)}; + return foo; // expected-warning {{implicit conversion changes signedness}} + +} +unsigned int test2() { + // For a non-defined enum, use the underlying type. + enum u8 : unsigned char; + u8 foo{static_cast<u8>(0)}; + return foo; +} |