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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [ext/] [has_trivial_assign.C] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// { dg-do "run" }
2
#include 
3
 
4
struct A
5
{
6
  double a;
7
  double b;
8
};
9
 
10
union U
11
{
12
  double a;
13
  double b;
14
};
15
 
16
struct B
17
{
18
  B& operator=(const B&) { return *this;}
19
};
20
 
21
struct C
22
{
23
  virtual int f() { return 1; }
24
};
25
 
26
struct D
27
: public B { };
28
 
29
struct E
30
: public A { };
31
 
32
struct F
33
{
34
  A a;
35
};
36
 
37
struct G
38
{
39
  B b;
40
};
41
 
42
template
43
  bool
44
  f()
45
  { return __has_trivial_assign(T); }
46
 
47
template
48
  class My
49
  {
50
  public:
51
    bool
52
    f()
53
    { return !!__has_trivial_assign(T); }
54
  };
55
 
56
template
57
  class My2
58
  {
59
  public:
60
    static const bool trait = __has_trivial_assign(T);
61
  };
62
 
63
template
64
  const bool My2::trait;
65
 
66
template
67
  struct My3_help
68
  { static const bool trait = b; };
69
 
70
template
71
  const bool My3_help::trait;
72
 
73
template
74
  class My3
75
  {
76
  public:
77
    bool
78
    f()
79
    { return My3_help::trait; }
80
  };
81
 
82
#define PTEST(T) (__has_trivial_assign(T) && f() \
83
                  && My().f() && My2::trait && My3().f())
84
 
85
#define NTEST(T) (!__has_trivial_assign(T) && !f() \
86
                  && !My().f() && !My2::trait && !My3().f())
87
 
88
int main()
89
{
90
  assert (PTEST (int));
91
  assert (NTEST (int (int)));
92
  assert (NTEST (void));
93
  assert (PTEST (A));
94
  assert (PTEST (U));
95
  assert (NTEST (B));
96
  assert (NTEST (C));
97
  assert (NTEST (D));
98
  assert (PTEST (E));
99
  assert (PTEST (E[]));
100
  assert (PTEST (F));
101
  assert (NTEST (G));
102
  assert (NTEST (const A));
103
  assert (NTEST (A&));
104
 
105
  return 0;
106
}

powered by: WebSVN 2.1.0

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