Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp0x/Wnarrowing17.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // PR c++/90805 - detect narrowing in case values. | |
2 // { dg-do compile { target c++11 } } | |
3 | |
4 void f(int i, char c, unsigned u) | |
5 { | |
6 switch (i) | |
7 { | |
8 case 2149056512u:; // { dg-error "narrowing conversion of .2149056512. from .unsigned int. to .int." } | |
9 case (long long int) 1e10:; // { dg-error "narrowing conversion of .10000000000. from .long long int. to .int." } | |
10 // { dg-warning "overflow in conversion" "overflow" { target *-*-* } .-1 } | |
11 } | |
12 | |
13 switch (c) | |
14 // No narrowing, the adjusted type is int. | |
15 case 300:; // { dg-warning "exceeds maximum value for type" } | |
16 | |
17 switch (u) | |
18 case -42:; // { dg-error "narrowing conversion of .-42. from .int. to .unsigned int." } | |
19 } |