summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/lvalue-9.c
blob: 382b3ffa903320de4fc86bfa58767617dbcd16cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* Test handling of lvalues of incomplete types.  Bugs 36941, 88647
   (invalid), 88827.  */
/* { dg-do compile } */
/* { dg-options "-std=c11 -pedantic-errors" } */

struct S;

extern struct S var;
extern struct S *vp;
extern int i;

void
f1 (void)
{
  var; /* { dg-error "has an incomplete type" } */
  var, (void) 0; /* { dg-error "has an incomplete type" } */
  (i
   ? var /* { dg-error "has an incomplete type" } */
   : var); /* { dg-error "has an incomplete type" } */
}

void
f2 (void)
{
  (void) var; /* { dg-error "has an incomplete type" } */
  (void) (var, (void) 0); /* { dg-error "has an incomplete type" } */
  (void) (i
	  ? var /* { dg-error "has an incomplete type" } */
	  : var); /* { dg-error "has an incomplete type" } */
}

void
f3 (void)
{
  (const void) var; /* { dg-error "has an incomplete type" } */
  (const void) (var, (void) 0); /* { dg-error "has an incomplete type" } */
  (const void) (i
		? var /* { dg-error "has an incomplete type" } */
		: var); /* { dg-error "has an incomplete type" } */
}

void
f4 (void)
{
  *vp; /* { dg-error "invalid use of undefined type" } */
  *vp, (void) 0; /* { dg-error "invalid use of undefined type" } */
  (i
   ? *vp /* { dg-error "invalid use of undefined type" } */
   : *vp); /* { dg-error "invalid use of undefined type" } */
}

void
f5 (void)
{
  (void) *vp; /* { dg-error "invalid use of undefined type" } */
  (void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */
  (void) (i
	  ? *vp /* { dg-error "invalid use of undefined type" } */
	  : *vp); /* { dg-error "invalid use of undefined type" } */
}

void
f6 (void)
{
  (const void) *vp; /* { dg-error "invalid use of undefined type" } */
  (const void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */
  (const void) (i
		? *vp /* { dg-error "invalid use of undefined type" } */
		: *vp); /* { dg-error "invalid use of undefined type" } */
}

void
f7 (void)
{
  /* This is invalid because of the constraints on [].  */
  &vp[0]; /* { dg-error "invalid use of undefined type" } */
}