|
1 | | -// RUN: %clang_cc1 -fsyntax-only -verify=c -Wimplicit-void-ptr-cast %s |
2 | | -// RUN: %clang_cc1 -fsyntax-only -verify=c -Wc++-compat %s |
| 1 | +// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify=c -Wimplicit-void-ptr-cast %s |
| 2 | +// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify=c -Wc++-compat %s |
3 | 3 | // RUN: %clang_cc1 -fsyntax-only -verify=cxx -x c++ %s |
4 | | -// RUN: %clang_cc1 -fsyntax-only -verify=good %s |
5 | | -// RUN: %clang_cc1 -fsyntax-only -verify=good -Wc++-compat -Wno-implicit-void-ptr-cast %s |
| 4 | +// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify=good %s |
| 5 | +// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify=good -Wc++-compat -Wno-implicit-void-ptr-cast %s |
6 | 6 | // good-no-diagnostics |
7 | 7 |
|
8 | 8 | typedef __typeof__(sizeof(int)) size_t; |
@@ -36,3 +36,27 @@ int *other_func(void *ptr) { |
36 | 36 | return ptr; // c-warning {{implicit conversion when returning 'void *' from a function with result type 'int *' is not permitted in C++}} \ |
37 | 37 | cxx-error {{cannot initialize return object of type 'int *' with an lvalue of type 'void *'}} |
38 | 38 | } |
| 39 | + |
| 40 | +void more(void) { |
| 41 | + __attribute__((address_space(0))) char *b1 = (void *)0; // c-warning {{implicit conversion when initializing '__attribute__((address_space(0))) char *' with an expression of type 'void *' is not permitted in C++}} \ |
| 42 | + cxx-error {{cannot initialize a variable of type '__attribute__((address_space(0))) char *' with an rvalue of type 'void *'}} |
| 43 | + __attribute__((address_space(0))) void *b2 = (void *)0; // c-warning {{implicit conversion when initializing '__attribute__((address_space(0))) void *' with an expression of type 'void *' is not permitted in C++}} \ |
| 44 | + cxx-error {{cannot initialize a variable of type '__attribute__((address_space(0))) void *' with an rvalue of type 'void *'}} |
| 45 | + char *b3 = (void *)0; // c-warning {{implicit conversion when initializing 'char *' with an expression of type 'void *' is not permitted in C++}} \ |
| 46 | + cxx-error {{cannot initialize a variable of type 'char *' with an rvalue of type 'void *'}} |
| 47 | + |
| 48 | + b1 = (void*)0; // c-warning {{implicit conversion when assigning to '__attribute__((address_space(0))) char *' from type 'void *' is not permitted in C++}} \ |
| 49 | + cxx-error {{assigning 'void *' to '__attribute__((address_space(0))) char *' changes address space of pointer}} |
| 50 | + |
| 51 | + b2 = (void*)0; // c-warning {{implicit conversion when assigning to '__attribute__((address_space(0))) void *' from type 'void *' is not permitted in C++}} \ |
| 52 | + cxx-error {{assigning 'void *' to '__attribute__((address_space(0))) void *' changes address space of pointer}} |
| 53 | + b2 = (__attribute__((address_space(0))) void *)0; |
| 54 | + b2 = nullptr; |
| 55 | + b2 = 0; |
| 56 | + |
| 57 | + b3 = (void*)0; // c-warning {{implicit conversion when assigning to 'char *' from type 'void *' is not permitted in C++}} \ |
| 58 | + cxx-error {{assigning to 'char *' from incompatible type 'void *'}} |
| 59 | + b3 = (char *)0; |
| 60 | + b3 = nullptr; |
| 61 | + b3 = 0; |
| 62 | +} |
0 commit comments