Home | History | Annotate | Download | only in SemaTemplate
      1 // RUN: %clang_cc1 -fsyntax-only %s -Wall
      2 
      3 template <typename T> class A { struct { }; };
      4 
      5 A<int> a0;
      6 
      7 template <typename T> struct B {
      8   union {
      9     int a;
     10     void* b;
     11   };
     12 
     13   void f() {
     14     a = 10;
     15     b = 0;
     16   }
     17 };
     18 
     19 B<int> b0;
     20 
     21 template <typename T> struct C {
     22   union {
     23     int a;
     24     void* b;
     25   };
     26 
     27   C(int a) : a(a) { }
     28   C(void* b) : b(b) { }
     29 };
     30 
     31 C<int> c0(0);
     32 
     33 namespace PR7088 {
     34   template<typename T>
     35   void f() {
     36     union {
     37       int a;
     38       union {
     39         float real;
     40         T d;
     41       };
     42     };
     43 
     44     a = 17;
     45     d = 3.14;
     46   }
     47 
     48   template void f<double>();
     49 }
     50 
     51 // Check for problems related to PR7402 that occur when template instantiation
     52 // instantiates implicit initializers.
     53 namespace PR7402 {
     54   struct X {
     55     union {
     56       struct {
     57         int x;
     58         int y;
     59       };
     60       int v[2];
     61     };
     62 
     63     // Check that this requirement survives instantiation.
     64     template <typename T> X(const T& t) : x(t), y(t) {}
     65   };
     66 
     67   X x(42.0);
     68 }
     69 
     70 namespace PR9188 {
     71   struct X0 {
     72     union {
     73       int member;
     74     };
     75   };
     76 
     77   static union {
     78     int global;
     79   };
     80 
     81   struct X1 : X0 {
     82     template<typename T>
     83     int f() {
     84       return this->X0::member + PR9188::global;
     85     }
     86   };
     87 
     88   template int X1::f<int>();
     89 }
     90