1 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
2
3 // This file tests -Wconstant-conversion, a subcategory of -Wconversion
4 // which is on by default.
5
nines()6 constexpr int nines() { return 99999; }
7
too_big_for_char(int param)8 void too_big_for_char(int param) {
9 char warn1 = false ? 0 : 99999;
10 // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes value from 99999 to -97}}
11 char warn2 = false ? 0 : nines();
12 // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes value from 99999 to -97}}
13
14 char warn3 = param > 0 ? 0 : 99999;
15 // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes value from 99999 to -97}}
16 char warn4 = param > 0 ? 0 : nines();
17 // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes value from 99999 to -97}}
18
19 char ok1 = true ? 0 : 99999;
20 char ok2 = true ? 0 : nines();
21
22 char ok3 = true ? 0 : 99999 + 1;
23 char ok4 = true ? 0 : nines() + 1;
24 }
25