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_nothrow_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
struct B
11
{
12
  A a;
13
};
14
 
15
struct C
16
: public A { };
17
 
18
struct D
19
{
20
  D& operator=(const D&) throw() { return *this; }
21
};
22
 
23
struct E
24
{
25
  E& operator=(const E&) throw(int) { return *this; }
26
};
27
 
28
struct E1
29
{
30
  E1& operator=(const E1&) throw(int) { throw int(); return *this; }
31
};
32
 
33
struct F
34
{
35
  F() throw(int) { }
36
};
37
 
38
struct G
39
{
40
  G() throw(int) { throw int(); }
41
};
42
 
43
struct H
44
{
45
  H& operator=(H&) throw(int) { return *this; }
46
};
47
 
48
struct H1
49
{
50
  H1& operator=(H1&) throw(int) { throw int(); return *this; }
51
};
52
 
53
struct I
54
{
55
  I& operator=(I&) throw(int) { return *this; }
56
  I& operator=(const I&) throw() { return *this; }
57
};
58
 
59
struct I1
60
{
61
  I1& operator=(I1&) throw(int) { throw int(); return *this; }
62
  I1& operator=(const I1&) throw() { return *this; }
63
};
64
 
65
struct J
66
{
67
  J& operator=(J&) throw() { return *this; }
68
  J& operator=(const J&) throw() { return *this; }
69
  J& operator=(volatile J&) throw() { return *this; }
70
  J& operator=(const volatile J&) throw() { return *this; }
71
};
72
 
73
struct K
74
{
75
  K& operator=(K&) throw() { return *this; }
76
};
77
 
78
struct L
79
{
80
  L& operator=(const L&) throw() { return *this; }
81
};
82
 
83
template
84
  bool
85
  f()
86
  { return __has_nothrow_assign(T); }
87
 
88
template
89
  class My
90
  {
91
  public:
92
    bool
93
    f()
94
    { return !!__has_nothrow_assign(T); }
95
  };
96
 
97
template
98
  class My2
99
  {
100
  public:
101
    static const bool trait = __has_nothrow_assign(T);
102
  };
103
 
104
template
105
  const bool My2::trait;
106
 
107
template
108
  struct My3_help
109
  { static const bool trait = b; };
110
 
111
template
112
  const bool My3_help::trait;
113
 
114
template
115
  class My3
116
  {
117
  public:
118
    bool
119
    f()
120
    { return My3_help::trait; }
121
  };
122
 
123
#define PTEST(T) (__has_nothrow_assign(T) && f() \
124
                  && My().f() && My2::trait && My3().f())
125
 
126
#define NTEST(T) (!__has_nothrow_assign(T) && !f() \
127
                  && !My().f() && !My2::trait && !My3().f())
128
 
129
int main()
130
{
131
  assert (PTEST (int));
132
  assert (NTEST (int (int)));
133
  assert (NTEST (void));
134
  assert (PTEST (A));
135
  assert (PTEST (B));
136
  assert (PTEST (C));
137
  assert (PTEST (C[]));
138
  assert (PTEST (D));
139
  assert (NTEST (E));
140
  assert (NTEST (E1));
141
  assert (PTEST (F));
142
  assert (PTEST (G));
143
  assert (NTEST (H));
144
  assert (NTEST (H1));
145
  assert (NTEST (I));
146
  assert (NTEST (I1));
147
  assert (PTEST (J));
148
  assert (NTEST (const K));
149
  assert (NTEST (const L));
150
 
151
  return 0;
152
}

powered by: WebSVN 2.1.0

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