xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/anonymous-union.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR5868
4*f4a2713aSLionel Sambuc struct T0 {
5*f4a2713aSLionel Sambuc   int x;
6*f4a2713aSLionel Sambuc   union {
7*f4a2713aSLionel Sambuc     void *m0;
8*f4a2713aSLionel Sambuc   };
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc template <typename T>
11*f4a2713aSLionel Sambuc struct T1 : public T0, public T {
f0T112*f4a2713aSLionel Sambuc   void f0() {
13*f4a2713aSLionel Sambuc     m0 = 0; // expected-error{{ambiguous conversion}}
14*f4a2713aSLionel Sambuc   }
15*f4a2713aSLionel Sambuc };
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc struct A : public T0 { };
18*f4a2713aSLionel Sambuc 
f1(T1<A> * S)19*f4a2713aSLionel Sambuc void f1(T1<A> *S) { S->f0(); } // expected-note{{instantiation of member function}}
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc namespace rdar8635664 {
22*f4a2713aSLionel Sambuc   template<typename T>
23*f4a2713aSLionel Sambuc   struct X {
24*f4a2713aSLionel Sambuc     struct inner;
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc     struct inner {
27*f4a2713aSLionel Sambuc       union {
28*f4a2713aSLionel Sambuc         int x;
29*f4a2713aSLionel Sambuc         float y;
30*f4a2713aSLionel Sambuc       };
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc       typedef T type;
33*f4a2713aSLionel Sambuc     };
34*f4a2713aSLionel Sambuc   };
35*f4a2713aSLionel Sambuc 
test()36*f4a2713aSLionel Sambuc   void test() {
37*f4a2713aSLionel Sambuc     X<int>::inner i;
38*f4a2713aSLionel Sambuc     i.x = 0;
39*f4a2713aSLionel Sambuc   }
40*f4a2713aSLionel Sambuc }
41