blob: f6489438070a76a4b2c8b7f90d5d855d89863209 [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}