|
1 | | -// RUN: %clang_cc1 -fsyntax-only -verify -Wimplicit-void-ptr-cast %s |
2 | | -// RUN: %clang_cc1 -fsyntax-only -verify -Wc++-compat %s |
| 1 | +// RUN: %clang_cc1 -fsyntax-only -verify=c -Wimplicit-void-ptr-cast %s |
| 2 | +// RUN: %clang_cc1 -fsyntax-only -verify=c -Wc++-compat %s |
| 3 | +// RUN: %clang_cc1 -fsyntax-only -verify=cxx -x c++ %s |
3 | 4 | // RUN: %clang_cc1 -fsyntax-only -verify=good %s |
4 | 5 | // RUN: %clang_cc1 -fsyntax-only -verify=good -Wc++-compat -Wno-implicit-void-ptr-cast %s |
5 | 6 | // good-no-diagnostics |
6 | 7 |
|
7 | 8 | typedef __typeof__(sizeof(int)) size_t; |
8 | 9 | extern void *malloc(size_t); |
9 | 10 |
|
10 | | -void func(int *); // expected-note {{passing argument to parameter here}} |
| 11 | +void func(int *); // #func-param |
11 | 12 |
|
12 | 13 | void test(void) { |
13 | | - int *x = malloc(sizeof(char)); // expected-warning {{implicit conversion when initializing 'int *' with an expression of type 'void *' is not permitted in C++}} |
14 | | - x = malloc(sizeof(char)); // expected-warning {{implicit conversion when assigning to 'int *' from type 'void *' is not permitted in C++}} |
15 | | - func(malloc(sizeof(char))); // expected-warning {{implicit conversion when passing 'void *' to parameter of type 'int *' is not permitted in C++}} |
| 14 | + int *x = malloc(sizeof(char)); // c-warning {{implicit conversion when initializing 'int *' with an expression of type 'void *' is not permitted in C++}} \ |
| 15 | + cxx-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'void *'}} |
| 16 | + x = malloc(sizeof(char)); // c-warning {{implicit conversion when assigning to 'int *' from type 'void *' is not permitted in C++}} \ |
| 17 | + cxx-error {{assigning to 'int *' from incompatible type 'void *'}} |
| 18 | + func(malloc(sizeof(char))); // c-warning {{implicit conversion when passing 'void *' to parameter of type 'int *' is not permitted in C++}} \ |
| 19 | + c-note@#func-param {{passing argument to parameter here}} \ |
| 20 | + cxx-error {{no matching function for call to 'func'}} \ |
| 21 | + cxx-note@#func-param {{candidate function not viable: cannot convert argument of incomplete type 'void *' to 'int *' for 1st argument}} |
16 | 22 | x = (int *)malloc(sizeof(char)); |
17 | 23 |
|
18 | 24 | void *vp = 0; |
19 | | - x = vp; // expected-warning {{implicit conversion when assigning to 'int *' from type 'void *' is not permitted in C++}} |
| 25 | + x = vp; // c-warning {{implicit conversion when assigning to 'int *' from type 'void *' is not permitted in C++}} \ |
| 26 | + cxx-error {{assigning to 'int *' from incompatible type 'void *'}} |
20 | 27 | vp = vp; |
21 | 28 |
|
22 | | - x = (void *)malloc(sizeof(char)); // expected-warning {{implicit conversion when assigning to 'int *' from type 'void *' is not permitted in C++}} |
23 | | - const int *y = vp; // expected-warning {{implicit conversion when initializing 'const int *' with an expression of type 'void *' is not permitted in C++}} |
| 29 | + x = (void *)malloc(sizeof(char)); // c-warning {{implicit conversion when assigning to 'int *' from type 'void *' is not permitted in C++}} \ |
| 30 | + cxx-error {{assigning to 'int *' from incompatible type 'void *'}} |
| 31 | + const int *y = vp; // c-warning {{implicit conversion when initializing 'const int *' with an expression of type 'void *' is not permitted in C++}} \ |
| 32 | + cxx-error {{cannot initialize a variable of type 'const int *' with an lvalue of type 'void *'}} |
24 | 33 | } |
25 | 34 |
|
26 | 35 | int *other_func(void *ptr) { |
27 | | - return ptr; // expected-warning {{implicit conversion when returning 'void *' from a function with result type 'int *' is not permitted in C++}} |
| 36 | + return ptr; // c-warning {{implicit conversion when returning 'void *' from a function with result type 'int *' is not permitted in C++}} \ |
| 37 | + cxx-error {{cannot initialize return object of type 'int *' with an lvalue of type 'void *'}} |
28 | 38 | } |
0 commit comments