-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Clang] Separate implicit int conversion on negation sign to new diagnostic group #139429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion | ||
| // RUN: %clang_cc1 %s -verify -Wimplicit-int-conversion -Wno-implicit-int-conversion-on-negation -DNO_DIAG | ||
|
||
|
|
||
| char test_char(char x) { | ||
| return -x; | ||
| #ifndef NO_DIAG | ||
| // expected-warning@-2 {{implicit conversion loses integer precision}} | ||
|
||
| #else | ||
| // expected-no-diagnostics | ||
| #endif | ||
| } | ||
|
|
||
| unsigned char test_unsigned_char(unsigned char x) { | ||
| return -x; | ||
| #ifndef NO_DIAG | ||
| // expected-warning@-2 {{implicit conversion loses integer precision}} | ||
| #else | ||
| // expected-no-diagnostics | ||
| #endif | ||
| } | ||
|
|
||
| short test_short(short x) { | ||
| return -x; | ||
| #ifndef NO_DIAG | ||
| // expected-warning@-2 {{implicit conversion loses integer precision}} | ||
| #else | ||
| // expected-no-diagnostics | ||
| #endif | ||
| } | ||
|
|
||
| unsigned short test_unsigned_short(unsigned short x) { | ||
| return -x; | ||
| #ifndef NO_DIAG | ||
| // expected-warning@-2 {{implicit conversion loses integer precision}} | ||
| #else | ||
| // expected-no-diagnostics | ||
| #endif | ||
| } | ||
|
|
||
| // --- int-width and wider (should NOT warn) --- | ||
|
|
||
| int test_i(int x) { | ||
| return -x; // no warning | ||
| } | ||
|
|
||
| unsigned int test_ui(unsigned int x) { | ||
| return -x; // no warning | ||
| } | ||
|
|
||
| long test_l(long x) { | ||
| return -x; // no warning | ||
| } | ||
|
|
||
| unsigned long test_ul(unsigned long x) { | ||
| return -x; // no warning | ||
| } | ||
|
|
||
| long long test_ll(long long x) { | ||
| return -x; // no warning | ||
| } | ||
|
|
||
| unsigned long long test_ull(unsigned long long x) { | ||
| return -x; // no warning | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.