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/] [g++.dg/] [other/] [offsetof2.C] - Blame information for rev 308

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// { dg-do run }
2
// { dg-options -Wold-style-cast }
3
 
4
// Copyright (C) 2003 Free Software Foundation, Inc.
5
// Contributed by Nathan Sidwell 22 Apr 2003 
6
 
7
// DR273 POD can have an operator&, offsetof is still required to work
8
 
9
#include 
10
 
11
struct POD1
12
{
13
  int m;
14
 
15
  void *operator& () const {return 0;} // yes, still a pod!
16
};
17
 
18
struct POD2
19
{
20
  int m;
21
};
22
 
23
void *operator& (POD2 const &) {return 0;} // ouch!
24
 
25
struct POD3
26
{
27
  int prefix;
28
 
29
  POD1 m;
30
};
31
 
32
struct POD4
33
{
34
  int prefix;
35
 
36
  POD1 m;
37
};
38
 
39
int main ()
40
{
41
  if (offsetof (POD3, m) != sizeof (int))
42
    return 1;
43
  if (offsetof (POD4, m) != sizeof (int))
44
    return 2;
45
  return 0;
46
}
47
 

powered by: WebSVN 2.1.0

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