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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [ext/] [has_nothrow_constructor.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 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() throw() { }
21
};
22
 
23
struct E
24
{
25
  E() throw(int) { }
26
};
27
 
28
struct E1
29
{
30
  E1() throw(int) { throw int(); }
31
};
32
 
33
struct F
34
{
35
  F(const F&) throw() { }
36
};
37
 
38
struct G
39
{
40
  G(const G&) throw(int) { throw int(); }
41
};
42
 
43
template
44
  bool
45
  f()
46
  { return __has_nothrow_constructor(T); }
47
 
48
template
49
  class My
50
  {
51
  public:
52
    bool
53
    f()
54
    { return !!__has_nothrow_constructor(T); }
55
  };
56
 
57
template
58
  class My2
59
  {
60
  public:
61
    static const bool trait = __has_nothrow_constructor(T);
62
  };
63
 
64
template
65
  const bool My2::trait;
66
 
67
 
68
template
69
  struct My3_help
70
  { static const bool trait = b; };
71
 
72
template
73
  const bool My3_help::trait;
74
 
75
template
76
  class My3
77
  {
78
  public:
79
    bool
80
    f()
81
    { return My3_help::trait; }
82
  };
83
 
84
#define PTEST(T) (__has_nothrow_constructor(T) && f() \
85
                  && My().f() && My2::trait && My3().f())
86
 
87
#define NTEST(T) (!__has_nothrow_constructor(T) && !f() \
88
                  && !My().f() && !My2::trait && !My3().f())
89
 
90
int main()
91
{
92
  assert (PTEST (int));
93
  assert (NTEST (int (int)));
94
  assert (NTEST (void));
95
  assert (PTEST (A));
96
  assert (PTEST (B));
97
  assert (PTEST (C));
98
  assert (PTEST (C[]));
99
  assert (PTEST (D));
100
  assert (NTEST (E));
101
  assert (NTEST (E1));
102
  assert (NTEST (F));
103
  assert (NTEST (G));
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.