blob: 958621266b76e2ee0d73cb7e91b4daf1f6529774 [file] [log] [blame]
John McCall091f23f2010-11-09 22:22:12 +00001// 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
6// rdar://problem/6792488
7void test_6792488(void) {
8 int x = 0x3ff0000000000000U; // expected-warning {{implicit conversion from 'unsigned long' to 'int' changes value from 4607182418800017408 to 0}}
9}
John McCallbeb22aa2010-11-09 23:24:47 +000010
11void test_7809123(void) {
12 struct { int i5 : 5; } a;
13
John McCall5dac4c22010-11-09 23:36:43 +000014 a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 36 to 4}}
John McCallbeb22aa2010-11-09 23:24:47 +000015}
John McCall935cd6e2010-11-10 00:26:50 +000016
17void test() {
18 struct { int bit : 1; } a;
19 a.bit = 1; // shouldn't warn
20}