xref: /llvm-project/clang/test/Sema/deref.c (revision e07ead85a368173a56e96a21d6841aa497ad80f8)
1 /* RUN: %clang_cc1 -fsyntax-only -verify -std=c90 -pedantic %s
2  */
3 void
foo(void)4 foo (void)
5 {
6  struct b;
7  struct b* x = 0;
8  struct b* y = &*x;
9 }
10 
foo2(void)11 void foo2 (void)
12 {
13  typedef int (*arrayptr)[];
14  arrayptr x = 0;
15  arrayptr y = &*x;
16 }
17 
foo3(void)18 void foo3 (void)
19 {
20  void* x = 0;
21  void* y = &*x; /* expected-warning{{address of an expression of type 'void'}}
22                    expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} */
23 }
24 
25 extern const void cv1;
26 
foo4(void)27 const void *foo4 (void)
28 {
29   return &cv1;
30 }
31 
32 extern void cv2;
foo5(void)33 void *foo5 (void)
34 {
35   return &cv2; /* expected-warning{{address of an expression of type 'void'}} */
36 }
37 
38 typedef const void CVT;
39 extern CVT cv3;
40 
foo6(void)41 const void *foo6 (void)
42 {
43   return &cv3;
44 }
45 
46