r326551 - [Sema] Improve test coverage of narrowing conversion diagnostics

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


Author: miyuki
Date: Fri Mar  2 02:03:02 2018
New Revision: 326551

URL: http://llvm.org/viewvc/llvm-project?rev=326551&view=rev
Log:
[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

Modified:
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp?rev=326551&r1=326550&r2=326551&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp Fri Mar  2 02:03:02 2018
@@ -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<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> 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<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.




More information about the cfe-commits mailing list