OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [anon-struct-11.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile } */
2
 
3
/* No special options--in particular, turn off the default
4
   -pedantic-errors option.  */
5
/* { dg-options "" } */
6
 
7
/* When not using -fplan9-extensions, we don't support automatic
8
   conversion of pointer types, and we don't support referring to a
9
   typedef name directly.  */
10
 
11
extern void exit (int);
12
extern void abort (void);
13
 
14
struct A { char a; };
15
 
16
struct B {
17
  char b;
18
  struct A;             /* { dg-warning "does not declare anything" } */
19
  char c;
20
};
21
 
22
void
23
f1 (struct A *p)        /* { dg-message "expected" } */
24
{
25
  p->a = 1;
26
}
27
 
28
void
29
test1 (void)
30
{
31
  struct B b;
32
  struct A *p;
33
 
34
  b.b = 2;
35
  b.c = 3;
36
  f1 (&b);              /* { dg-warning "incompatible pointer type" } */
37
  if (b.a != 1)         /* { dg-error "no member" } */
38
    abort ();
39
  if (b.b != 2 || b.c != 3)
40
    abort ();
41
  p = &b;               /* { dg-warning "incompatible pointer type" } */
42
  if (p->a != 1)
43
    abort ();
44
}
45
 
46
typedef struct { char d; } D;
47
 
48
struct E {
49
  char b;
50
  struct F { char f; }; /* { dg-warning "does not declare anything" } */
51
  char c;
52
  union {
53
    D;                  /* { dg-warning "does not declare anything" } */
54
  };
55
  char e;
56
};
57
 
58
void
59
f2 (struct F *p)        /* { dg-message "expected" } */
60
{
61
  p->f = 6;
62
}
63
 
64
void
65
f3 (D *p)               /* { dg-message "expected" } */
66
{
67
  p->d = 4;
68
}
69
 
70
void
71
f4 (D d)
72
{
73
}
74
 
75
void
76
test2 (void)
77
{
78
  struct E e;
79
  struct F *pf;
80
  D *pd;
81
  D d;
82
 
83
  e.b = 2;
84
  e.c = 3;
85
  e.e = 5;
86
  f2 (&e);              /* { dg-warning "incompatible pointer type" } */
87
  f3 (&e);              /* { dg-warning "incompatible pointer type" } */
88
  if (e.d != 4)         /* { dg-error "no member" } */
89
    abort ();
90
  if (e.f != 6)         /* { dg-error "no member" } */
91
    abort ();
92
  if (e.b != 2 || e.c != 3 || e.e != 5)
93
    abort ();
94
  pf = &e;              /* { dg-warning "incompatible pointer type" } */
95
  if (pf->f != 6)
96
    abort ();
97
  pd = &e;              /* { dg-warning "incompatible pointer type" } */
98
  if (pd->d != 4)
99
    abort ();
100
  d = e.D;              /* { dg-error "no member" } */
101
  f3 (&e.D);            /* { dg-error "no member" } */
102
  f4 (e.D);             /* { dg-error "no member" } */
103
}
104
 
105
int
106
main ()
107
{
108
  test1 ();
109
  test2 ();
110
  exit (0);
111
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.