| 1 |
// RUN: %clang_cc1 -verify -std=c2y %s |
| 2 |
// RUN: %clang_cc1 -verify -std=c23 %s |
| 3 |
|
| 4 |
/* WG14 N3481: Yes |
| 5 |
* Slay Some Earthly Demons XVI |
| 6 |
* |
| 7 |
* It was previously UB to use a non-array lvalue with an incomplete type in a |
| 8 |
* context which required the value of the object. Clang has always diagnosed |
| 9 |
* this as an error, except when the incomplete type is void. Then we allow the |
| 10 |
* dereference, but not for a value computation. |
| 11 |
*/ |
| 12 |
|
| 13 |
struct f *p; // expected-note {{forward declaration of 'struct f'}} |
| 14 |
void g(void) { |
| 15 |
(void)*p; // expected-error {{incomplete type 'struct f' where a complete type is required}} |
| 16 |
} |
| 17 |
|
| 18 |
void h(void *ptr) { |
| 19 |
(void)*ptr; // expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} |
| 20 |
(*ptr)++; /* expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} |
| 21 |
expected-error {{cannot increment value of type 'void'}} |
| 22 |
*/ |
| 23 |
} |