Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/cpp0x/Wnarrowing17.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
line wrap: on
line source
// PR c++/90805 - detect narrowing in case values. // { dg-do compile { target c++11 } } void f(int i, char c, unsigned u) { switch (i) { case 2149056512u:; // { dg-error "narrowing conversion of .2149056512. from .unsigned int. to .int." } case (long long int) 1e10:; // { dg-error "narrowing conversion of .10000000000. from .long long int. to .int." } // { dg-warning "overflow in conversion" "overflow" { target *-*-* } .-1 } } switch (c) // No narrowing, the adjusted type is int. case 300:; // { dg-warning "exceeds maximum value for type" } switch (u) case -42:; // { dg-error "narrowing conversion of .-42. from .int. to .unsigned int." } }