1 /* Test handling of lvalues of incomplete types.  Bugs 36941, 88647
2    (invalid), 88827.  */
3 /* { dg-do compile } */
4 /* { dg-options "-std=c11 -pedantic-errors" } */
5 
6 struct S;
7 
8 extern struct S var;
9 extern struct S *vp;
10 extern int i;
11 
12 void
f1(void)13 f1 (void)
14 {
15   var; /* { dg-error "has an incomplete type" } */
16   var, (void) 0; /* { dg-error "has an incomplete type" } */
17   (i
18    ? var /* { dg-error "has an incomplete type" } */
19    : var); /* { dg-error "has an incomplete type" } */
20 }
21 
22 void
f2(void)23 f2 (void)
24 {
25   (void) var; /* { dg-error "has an incomplete type" } */
26   (void) (var, (void) 0); /* { dg-error "has an incomplete type" } */
27   (void) (i
28 	  ? var /* { dg-error "has an incomplete type" } */
29 	  : var); /* { dg-error "has an incomplete type" } */
30 }
31 
32 void
f3(void)33 f3 (void)
34 {
35   (const void) var; /* { dg-error "has an incomplete type" } */
36   (const void) (var, (void) 0); /* { dg-error "has an incomplete type" } */
37   (const void) (i
38 		? var /* { dg-error "has an incomplete type" } */
39 		: var); /* { dg-error "has an incomplete type" } */
40 }
41 
42 void
f4(void)43 f4 (void)
44 {
45   *vp; /* { dg-error "invalid use of undefined type" } */
46   *vp, (void) 0; /* { dg-error "invalid use of undefined type" } */
47   (i
48    ? *vp /* { dg-error "invalid use of undefined type" } */
49    : *vp); /* { dg-error "invalid use of undefined type" } */
50 }
51 
52 void
f5(void)53 f5 (void)
54 {
55   (void) *vp; /* { dg-error "invalid use of undefined type" } */
56   (void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */
57   (void) (i
58 	  ? *vp /* { dg-error "invalid use of undefined type" } */
59 	  : *vp); /* { dg-error "invalid use of undefined type" } */
60 }
61 
62 void
f6(void)63 f6 (void)
64 {
65   (const void) *vp; /* { dg-error "invalid use of undefined type" } */
66   (const void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */
67   (const void) (i
68 		? *vp /* { dg-error "invalid use of undefined type" } */
69 		: *vp); /* { dg-error "invalid use of undefined type" } */
70 }
71 
72 void
f7(void)73 f7 (void)
74 {
75   /* This is invalid because of the constraints on [].  */
76   &vp[0]; /* { dg-error "invalid use of undefined type" } */
77 }
78