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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [struct-union.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O -Wall" } */
3
 
4
/* C99 6.5.2.3 Structure and union members.
5
   If the first expression has qualified type, the result has the so-qualified
6
   version of the type of the designated member.  */
7
 
8
struct s {_Decimal32 d32; const _Decimal64 d64;};
9
struct sv { volatile _Decimal32 d32; volatile _Decimal64 d64; };
10
union u
11
{
12
  const _Decimal64 d64;
13
  _Decimal32 d32;
14
  const struct s cs;
15
};
16
 
17
struct s s;
18
struct sv sv;
19
const struct s cs;
20
 
21
union u u;
22
const union u cu;
23
 
24
struct s g (struct s s)
25
{
26
  return s;
27
}
28
 
29
union u h (union u u)
30
{
31
  return u;
32
}
33
 
34
void f()
35
{
36
  cs.d32 = 1.23dd; /* { dg-error "assignment of read-only variable" } */
37
  cs.d64 = 1.23df; /* { dg-error "assignment of read-only variable" } */
38
  s.d64 = 1.23df;  /* { dg-error "assignment of read-only member" } */
39
 
40
  s.d32 = 1.23dd;
41
  u.d32 = 1.23dd;
42
 
43
  u.d64 = 1.23df;    /* { dg-error "assignment of read-only member" } */
44
  u.cs.d32 = 1.23dd; /* { dg-error "assignment of read-only member" } */
45
  u.cs.d64 = 1.23df; /* { dg-error "assignment of read-only member" } */
46
 
47
  cu.d32 = 1.23dd;   /* { dg-error "assignment of read-only variable" } */
48
 
49
  cu.d64 = 1.23df;    /* { dg-error "assignment of read-only variable" } */
50
  cu.cs.d32 = 1.23dd; /* { dg-error "assignment of read-only variable" } */
51
  cu.cs.d64 = 1.23df; /* { dg-error "assignment of read-only variable" } */
52
 
53
  /* f().x is a valid postfix expression but is not an lvalue if
54
     function f() returning a structure or union.  */
55
  g(s).d32 = 1.23dd;  /* { dg-error "lvalue required" } */
56
  h(u).d64 = 1.23df;  /* { dg-error "lvalue required" } */
57
 
58
  /* Test assignment to volatile structure members.  */
59
  sv.d32 = 1.1df;
60
  sv.d64 = 1.1dd;
61
}
62
 

powered by: WebSVN 2.1.0

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