[PATCH] D43572: [Sema] Improve test coverage of narrowing conversion diagnostics

Mikhail Maltsev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 2 02:05:19 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC326551: [Sema] Improve test coverage of narrowing conversion diagnostics (authored by miyuki, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43572

Files:
  test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp


Index: test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
===================================================================
--- test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
+++ test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
@@ -147,8 +147,10 @@
 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 @@
   // 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43572.136702.patch
Type: text/x-patch
Size: 2107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180302/1169c96d/attachment.bin>


More information about the cfe-commits mailing list