blob: f6004f0fc8b239e0766e6f8db8eec21f21869e52 [file] [log] [blame]
Richard Smithbe3980b2015-03-27 00:41:57 +00001struct A { int a_member; };
Richard Smith9a71c992015-03-27 20:16:58 +00002inline int use_a(A a) { return a.a_member; }
Richard Smithbe3980b2015-03-27 00:41:57 +00003
Richard Smith65ebb4a2015-03-26 04:09:53 +00004class B {
5 struct Inner1 {};
Richard Smithbe3980b2015-03-27 00:41:57 +00006public:
Richard Smith65ebb4a2015-03-26 04:09:53 +00007 struct Inner2;
Richard Smith6dc8ae12015-08-17 20:24:17 +00008 struct Inner3;
Richard Smithd6aab592015-03-27 21:57:41 +00009 template<typename T> void f();
Richard Smith65ebb4a2015-03-26 04:09:53 +000010};
Richard Smith6dc8ae12015-08-17 20:24:17 +000011struct BFriend {
12 friend class B::Inner3;
13private:
14 struct Inner3Base {};
15};
Richard Smithbe3980b2015-03-27 00:41:57 +000016// Check that lookup and access checks are performed in the right context.
Richard Smith65ebb4a2015-03-26 04:09:53 +000017struct B::Inner2 : Inner1 {};
Richard Smith6dc8ae12015-08-17 20:24:17 +000018struct B::Inner3 : BFriend::Inner3Base {};
Richard Smithd6aab592015-03-27 21:57:41 +000019template<typename T> void B::f() {}
Richard Smith5327b892015-07-01 19:32:54 +000020template<> inline void B::f<int>() {}
Richard Smithbe3980b2015-03-27 00:41:57 +000021
22// Check that base-specifiers are correctly disambiguated.
23template<int N> struct C_Base { struct D { constexpr operator int() const { return 0; } }; };
24const int C_Const = 0;
25struct C1 : C_Base<C_Base<0>::D{}> {} extern c1;
26struct C2 : C_Base<C_Const<0>::D{} extern c2;
Richard Smitha5230222015-03-27 01:37:43 +000027
28typedef struct { int a; void f(); struct X; } D;
29struct D::X { int dx; } extern dx;
Richard Smith9a71c992015-03-27 20:16:58 +000030inline int use_dx(D::X dx) { return dx.dx; }
Richard Smithd6aab592015-03-27 21:57:41 +000031
32template<typename T> int E(T t) { return t; }
33
34template<typename T> struct F {
35 int f();
36 template<typename U> int g();
Richard Smith82e57fb2015-05-19 00:49:29 +000037 static int n;
Richard Smithd6aab592015-03-27 21:57:41 +000038};
39template<typename T> int F<T>::f() { return 0; }
40template<typename T> template<typename U> int F<T>::g() { return 0; }
Richard Smith82e57fb2015-05-19 00:49:29 +000041template<typename T> int F<T>::n = 0;
Richard Smith5327b892015-07-01 19:32:54 +000042template<> inline int F<char>::f() { return 0; }
43template<> template<typename U> int F<char>::g() { return 0; }
Richard Smithc7e6ff02015-05-18 20:36:47 +000044template<> struct F<void> { int h(); };
45inline int F<void>::h() { return 0; }
46template<typename T> struct F<T *> { int i(); };
47template<typename T> int F<T*>::i() { return 0; }
Richard Smithd9ba2242015-05-07 03:54:19 +000048
49namespace G {
50 enum A { a, b, c, d, e };
51 enum { f, g, h };
52 typedef enum { i, j } k;
53 typedef enum {} l;
54}
Richard Smithc7d48d12015-05-20 17:50:35 +000055
Richard Smithfd8b64e2015-05-20 18:24:21 +000056template<typename T = int, int N = 3, template<typename> class K = F> int H(int a = 1);
57template<typename T = int, int N = 3, template<typename> class K = F> using I = decltype(H<T, N, K>());
Richard Smithc7852762015-06-11 23:46:11 +000058template<typename T = int, int N = 3, template<typename> class K = F> struct J {};
Richard Smith00be6d02015-06-11 03:05:39 +000059
60namespace NS {
61 struct A {};
Richard Smith0f192e82015-06-11 22:48:25 +000062 template<typename T> struct B : A {};
63 template<typename T> struct B<T*> : B<char> {};
64 template<> struct B<int> : B<int*> {};
Richard Smith00be6d02015-06-11 03:05:39 +000065 inline void f() {}
66}
Richard Smitha1431072015-06-12 01:32:13 +000067
68namespace StaticInline {
69 struct X {};
70 static inline void f(X);
71 static inline void g(X x) { f(x); }
72}
Richard Smith52933792015-06-16 21:57:05 +000073
74namespace FriendDefArg {
75 template<typename = int> struct A;
76 template<int = 0> struct B;
77 template<template<typename> class = A> struct C;
Richard Smithafe800c2015-06-17 22:13:23 +000078 template<typename = int, int = 0, template<typename> class = A> struct D {};
Richard Smith52933792015-06-16 21:57:05 +000079 template<typename U> struct Y {
80 template<typename> friend struct A;
81 template<int> friend struct B;
82 template<template<typename> class> friend struct C;
Richard Smithafe800c2015-06-17 22:13:23 +000083 template<typename, int, template<typename> class> friend struct D;
Richard Smith52933792015-06-16 21:57:05 +000084 };
85}
Richard Smith76553812015-07-01 07:24:18 +000086
87namespace SeparateInline {
88 inline void f();
89 void f() {}
90 constexpr int g() { return 0; }
91}
Richard Smith04c6c1f2015-07-01 18:56:50 +000092
93namespace TrailingAttributes {
94 template<typename T> struct X {} __attribute__((aligned(8)));
95}
Richard Smithda6c2342015-07-01 23:19:58 +000096
97namespace MergeFunctionTemplateSpecializations {
98 template<typename T> T f();
99 template<typename T> struct X {
100 template<typename U> using Q = decltype(f<T>() + U());
101 };
102 using xiq = X<int>::Q<int>;
103}
Richard Smithb1d8ea42015-07-08 21:49:31 +0000104
105enum ScopedEnum : int;
106enum ScopedEnum : int { a, b, c };
Richard Smith826711d2015-07-29 23:38:25 +0000107
108namespace RedeclDifferentDeclKind {
109 struct X {};
110 typedef X X;
111 using RedeclDifferentDeclKind::X;
112}
Richard Smith8cbd8952015-08-04 02:05:09 +0000113
114namespace Anon {
115 struct X {
116 union {
117 int n;
118 };
119 };
120}
Richard Smith2bb3c342015-08-09 01:05:31 +0000121
122namespace ClassTemplatePartialSpec {
123 template<typename T> struct F;
124 template<template<int> class A, int B> struct F<A<B>> {
125 template<typename C> F();
126 };
127 template<template<int> class A, int B> template<typename C> F<A<B>>::F() {}
128
129 template<typename A, int B> struct F<A[B]> {
130 template<typename C> F();
131 };
132 template<typename A, int B> template<typename C> F<A[B]>::F() {}
133}
Richard Smith84824ed2015-12-11 22:39:52 +0000134
135struct MemberClassTemplate {
136 template<typename T> struct A;
137};
138template<typename T> struct MemberClassTemplate::A {};
139template<typename T> struct MemberClassTemplate::A<T*> {};
140template<> struct MemberClassTemplate::A<int> {};