-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NFC: Pre-commit test: -Wpointer-sign with plain char to [un]signed char
Add tests with bad message text for `-Wpointer-sign` and run them with both signed and unsigned versions of plain `char`.
- Loading branch information
1 parent
7470017
commit f635bcd
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
// RUN: %clang_cc1 %s -verify -fsyntax-only | ||
// RUN: %clang_cc1 %s -verify -fsyntax-only -fno-signed-char | ||
|
||
int a(int* x); // expected-note{{passing argument to parameter 'x' here}} | ||
int b(unsigned* y) { return a(y); } // expected-warning {{passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign}} | ||
|
||
signed char *plainCharToSignedChar(signed char *arg) { // expected-note{{passing argument to parameter}} | ||
extern char c; | ||
signed char *p = &c; // expected-warning {{converts between pointers to integer types with different sign}} | ||
struct { signed char *p; } s = { &c }; // expected-warning {{converts between pointers to integer types with different sign}} | ||
p = &c; // expected-warning {{converts between pointers to integer types with different sign}} | ||
plainCharToSignedChar(&c); // expected-warning {{converts between pointers to integer types with different sign}} | ||
return &c; // expected-warning {{converts between pointers to integer types with different sign}} | ||
} | ||
|
||
char *unsignedCharToPlainChar(char *arg) { // expected-note{{passing argument to parameter}} | ||
extern unsigned char uc[]; | ||
char *p = uc; // expected-warning {{converts between pointers to integer types with different sign}} | ||
(void) (char *[]){ [42] = uc }; // expected-warning {{converts between pointers to integer types with different sign}} | ||
p = uc; // expected-warning {{converts between pointers to integer types with different sign}} | ||
unsignedCharToPlainChar(uc); // expected-warning {{converts between pointers to integer types with different sign}} | ||
return uc; // expected-warning {{converts between pointers to integer types with different sign}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// RUN: %clang_cc1 %s -verify -fsyntax-only | ||
// RUN: %clang_cc1 %s -verify -fsyntax-only -fno-signed-char | ||
|
||
void plainToSigned() { | ||
extern char c; | ||
signed char *p; | ||
p = &c; // expected-error {{converts between pointers to integer types with different sign}} | ||
} | ||
|
||
void unsignedToPlain() { | ||
extern unsigned char uc; | ||
char *p; | ||
p = &uc; // expected-error {{converts between pointers to integer types with different sign}} | ||
} |