[PATCH] D52137: Added warning for unary minus used with unsigned type

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 1 18:21:56 PDT 2018


rsmith added inline comments.


================
Comment at: test/Sema/unary-minus-integer-impcast-2.c:1
+// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only -triple i386-pc-linux-gnu
+
----------------
You can combine the two tests together into a single file using a #ifdef to detect which set of warnings to expect:

```
unsigned long b2 = -a;
#ifdef __X86_64__
// expected-warning at -2 {{higher order bits are zeroes}}
#endif
long c2 = -a;
#ifdef __X86_64__
// expected-warning at -2 {{value is always non-negative}}
#else
// expected-warning at -4 {{implicit conversion changes signedness}}
#endif
```


https://reviews.llvm.org/D52137





More information about the cfe-commits mailing list