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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [ext/] [is_union.C] - Blame information for rev 308

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

powered by: WebSVN 2.1.0

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