Skip to content

Commit 19362f3

Browse files
committed
Add test coverage
1 parent 6360cf5 commit 19362f3

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

clang/test/Sema/implicit-void-ptr-cast.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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
33
// 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
66
// good-no-diagnostics
77

88
typedef __typeof__(sizeof(int)) size_t;
@@ -36,3 +36,27 @@ int *other_func(void *ptr) {
3636
return ptr; // c-warning {{implicit conversion when returning 'void *' from a function with result type 'int *' is not permitted in C++}} \
3737
cxx-error {{cannot initialize return object of type 'int *' with an lvalue of type 'void *'}}
3838
}
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

Comments
 (0)