[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / ext / is_union.C
blobc95f5a6e561436984ea05da947084343192f9647
1 // { dg-do run }
2 #include <cassert>
4 struct A
6   double a;
7   double b;
8 };
10 class B
12   B() { }
15 union U
16
17   double a;
18   double b;  
21 template<typename T>
22   bool
23   f()
24   { return __is_union(T); } 
26 template<typename T>
27   class My
28   {
29   public:
30     bool
31     f()
32     { return !!__is_union(T); }
33   };
35 template<typename T>
36   class My2
37   {
38   public:
39     static const bool trait = __is_union(T);
40   };
42 template<typename T>
43   const bool My2<T>::trait;
45 template<typename T, bool b = __is_union(T)>
46   struct My3_help
47   { static const bool trait = b; };
49 template<typename T, bool b>
50   const bool My3_help<T, b>::trait;
52 template<typename T>
53   class My3
54   {
55   public:
56     bool
57     f()
58     { return My3_help<T>::trait; }
59   };
61 #define PTEST(T) (__is_union(T) && f<T>() \
62                   && My<T>().f() && My2<T>::trait && My3<T>().f())
64 #define NTEST(T) (!__is_union(T) && !f<T>() \
65                   && !My<T>().f() && !My2<T>::trait && !My3<T>().f())
67 int main()
69   assert (NTEST (int));
70   assert (NTEST (void));
71   assert (NTEST (A));
72   assert (NTEST (B));
73   assert (PTEST (U));
75   return 0;