blob: 68b233a7fda7d47d04313a27a2ab8543b84d635b [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only %s -Wall
Douglas Gregora5bf7f12009-08-28 22:03:51 +00002
3template <typename T> class A { struct { }; };
4
5A<int> a0;
6
Anders Carlssond8b285f2009-09-01 04:26:58 +00007template <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
19B<int> b0;
Anders Carlsson9988d5d2009-09-01 04:31:02 +000020
21template <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
Anders Carlssoncdc83c72009-09-01 06:22:14 +000031C<int> c0(0);
Douglas Gregor9901c572010-05-21 00:31:19 +000032
33namespace 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}
Chandler Carruth030ef472010-09-03 21:54:20 +000050
51// Check for problems related to PR7402 that occur when template instantiation
52// instantiates implicit initializers.
53namespace 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}
Douglas Gregorf5848322011-02-18 02:44:58 +000069
70namespace 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}