summaryrefslogtreecommitdiff
path: root/test/Sema/unary-minus-integer-impcast.c
blob: 0eb4401758817f0d1b0de88e9cf09dfad8eafee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only -triple x86_64-pc-linux-gnu
// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only -triple i386-pc-linux-gnu

void test(void) {
  unsigned int a = 1;

  unsigned long long b = -a; // expected-warning {{higher order bits are zeroes after implicit conversion}}
  long long c = -a;          // expected-warning {{the resulting value is always non-negative after implicit conversion}}

  unsigned long b2 = -a;
#ifdef __x86_64__
// expected-warning@-2 {{higher order bits are zeroes after implicit conversion}}
#endif
  long c2 = -a;
#ifdef __x86_64__
// expected-warning@-2 {{the resulting value is always non-negative after implicit conversion}}
#else
// expected-warning@-4 {{implicit conversion changes signedness: 'unsigned int' to 'long'}}
#endif
}