blob: fdda7ac76acd5585515ff8e967221808952b50c0 [file] [log] [blame]
John McCallecda6fb2010-07-13 06:26:23 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s
2
3typedef signed char int8_t;
4typedef signed short int16_t;
5typedef signed int int32_t;
6typedef signed long int64_t;
7
8typedef unsigned char uint8_t;
9typedef unsigned short uint16_t;
10typedef unsigned int uint32_t;
11typedef unsigned long uint64_t;
12
13// <rdar://problem/7909130>
14namespace test0 {
15 int32_t test1_positive(char *I, char *E) {
16 return (E - I); // expected-warning {{implicit conversion loses integer precision}}
17 }
18
19 int32_t test1_negative(char *I, char *E) {
20 return static_cast<int32_t>(E - I);
21 }
22
23 uint32_t test2_positive(uint64_t x) {
24 return x; // expected-warning {{implicit conversion loses integer precision}}
25 }
26
27 uint32_t test2_negative(uint64_t x) {
28 return (uint32_t) x;
29 }
30}
31
32namespace test1 {
33 uint64_t test1(int x, unsigned y) {
34 return sizeof(x == y);
35 }
36
37 uint64_t test2(int x, unsigned y) {
38 return __alignof(x == y);
39 }
40
41 void * const foo();
42 bool test2(void *p) {
43 return p == foo();
44 }
45}
John McCall15d7d122010-11-11 03:21:53 +000046
47namespace test2 {
48 struct A {
49 unsigned int x : 2;
50 A() : x(10) {} // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
51 };
52}