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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [torture/] [pr51436.C] - Blame information for rev 749

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

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-do compile } */
2
 
3
typedef __SIZE_TYPE__ size_t;
4
extern "C" void *memcpy (void *, __const void *, size_t);
5
template < class Dest, class Source > struct BitCastHelper {
6
    static Dest cast (const Source & source) __attribute__ ((always_inline)) {
7
        Dest dest;
8
        memcpy (0, &source, sizeof dest);
9
    }
10
};
11
template < class Dest, class Source > Dest BitCast (Source)
12
{
13
  BitCastHelper < Dest, Source >::cast (0);
14
}
15
 
16
class MaybeObject
17
{
18
};
19
class Object:MaybeObject
20
{
21
public:
22
    static Object *cast (Object *) {
23
    }
24
};
25
class HeapObject:public Object
26
{
27
};
28
class String:public HeapObject
29
{
30
};
31
class ExternalString:public String
32
{
33
};
34
class ExternalTwoByteString:public ExternalString
35
{
36
};
37
 
38
template < typename T > class Handle
39
{
40
public:
41
    Handle () {
42
    }
43
    T *operator* () const;
44
    template < class S > static Handle < T > cast (Handle < S > that) {
45
        T::cast (*that);
46
    }
47
    T **location_;
48
};
49
 
50
template < typename T > T * Handle < T >::operator* () const
51
{
52
  *BitCast < T ** >(location_);
53
}
54
 
55
void
56
TestCharacterStream ()
57
{
58
  Handle < String > uc16_string;
59
  Handle < ExternalTwoByteString >::cast (uc16_string);
60
}

powered by: WebSVN 2.1.0

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