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`.
This commit is contained in:
parent
7470017f24
commit
f635bcd161
@ -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}}
|
||||
}
|
||||
|
||||
14
clang/test/Sema/incompatible-sign.cpp
Normal file
14
clang/test/Sema/incompatible-sign.cpp
Normal file
@ -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}}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user