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

Subversion Repositories openrisc

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

Go to most recent revision | 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
union U
11
{
12
  double a;
13
  double b;
14
};
15
 
16
struct B
17
{
18
  B() { }
19
};
20
 
21
struct C
22
: public B { };
23
 
24
struct D
25
: public A { };
26
 
27
struct E
28
{
29
  A a;
30
};
31
 
32
struct F
33
{
34
  B b;
35
};
36
 
37
template
38
  bool
39
  f()
40
  { return __has_trivial_constructor(T); }
41
 
42
template
43
  class My
44
  {
45
  public:
46
    bool
47
    f()
48
    { return !!__has_trivial_constructor(T); }
49
  };
50
 
51
template
52
  class My2
53
  {
54
  public:
55
    static const bool trait = __has_trivial_constructor(T);
56
  };
57
 
58
template
59
  const bool My2::trait;
60
 
61
template
62
  struct My3_help
63
  { static const bool trait = b; };
64
 
65
template
66
  const bool My3_help::trait;
67
 
68
template
69
  class My3
70
  {
71
  public:
72
    bool
73
    f()
74
    { return My3_help::trait; }
75
  };
76
 
77
#define PTEST(T) (__has_trivial_constructor(T) && f() \
78
                  && My().f() && My2::trait && My3().f())
79
 
80
#define NTEST(T) (!__has_trivial_constructor(T) && !f() \
81
                  && !My().f() && !My2::trait && !My3().f())
82
 
83
int main()
84
{
85
  assert (PTEST (int));
86
  assert (NTEST (int (int)));
87
  assert (NTEST (void));
88
  assert (PTEST (A));
89
  assert (PTEST (U));
90
  assert (NTEST (B));
91
  assert (NTEST (C));
92
  assert (PTEST (D));
93
  assert (PTEST (D[]));
94
  assert (PTEST (E));
95
  assert (NTEST (F));
96
 
97
  return 0;
98
}

powered by: WebSVN 2.1.0

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