diff options
| author | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-03-02 10:03:02 +0000 |
|---|---|---|
| committer | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-03-02 10:03:02 +0000 |
| commit | 2373516cad08ec38d3c10fafd7d62937893ede10 (patch) | |
| tree | ba08c27c5a1508713406d45420ffb86f22cb7635 | |
| parent | fdaeb9bfb27d8bd6cfd5d2b07f17aefd7c89b0ad (diff) | |
| download | bcm5719-llvm-2373516cad08ec38d3c10fafd7d62937893ede10.tar.gz bcm5719-llvm-2373516cad08ec38d3c10fafd7d62937893ede10.zip | |
[Sema] Improve test coverage of narrowing conversion diagnostics
Summary:
This patch adds tests of narrowing conversion diagnostics for the
'unscoped enum -> integer' case.
Reviewers: faisalv, rsmith, rogfer01
Reviewed By: rogfer01
Subscribers: cfe-commits, rogfer01
Differential Revision: https://reviews.llvm.org/D43572
llvm-svn: 326551
| -rw-r--r-- | clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp index 2142c098f88..4436cb0aac6 100644 --- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp @@ -147,8 +147,10 @@ void int_to_float() { void shrink_int() { // Not a constant expression. short s = 1; + UnscopedEnum e = EnumVal; unsigned short us = 1; Agg<char> c1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} + Agg<char> c2 = {e}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} Agg<unsigned short> s1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} Agg<short> s2 = {us}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} @@ -158,16 +160,19 @@ void shrink_int() { // long). long l1 = 1; Agg<int> i1 = {l1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} + Agg<int> i2 = {e}; // OK long long ll = 1; Agg<long> l2 = {ll}; // OK // Constants. - Agg<char> c2 = {127}; // OK - Agg<char> c3 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - - Agg<int> i2 = {0x7FFFFFFFU}; // OK - Agg<int> i3 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<unsigned int> i4 = {-0x80000000L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} + Agg<char> c3 = {127}; // OK + Agg<char> c4 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} + Agg<char> c5 = {EnumVal}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} + + Agg<int> i3 = {0x7FFFFFFFU}; // OK + Agg<int> i4 = {EnumVal}; // OK + Agg<int> i5 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} + Agg<unsigned int> i6 = {-0x80000000L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} // Bool is also an integer type, but conversions to it are a different AST // node. |

