blob: 247b05c47082c757e9fe0d3cbaf6ca5bdcf51510 [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 Smithd6aab592015-03-27 21:57:41 +00008 template<typename T> void f();
Richard Smith65ebb4a2015-03-26 04:09:53 +00009};
Richard Smithbe3980b2015-03-27 00:41:57 +000010// Check that lookup and access checks are performed in the right context.
Richard Smith65ebb4a2015-03-26 04:09:53 +000011struct B::Inner2 : Inner1 {};
Richard Smithd6aab592015-03-27 21:57:41 +000012template<typename T> void B::f() {}
Richard Smithbe3980b2015-03-27 00:41:57 +000013
14// Check that base-specifiers are correctly disambiguated.
15template<int N> struct C_Base { struct D { constexpr operator int() const { return 0; } }; };
16const int C_Const = 0;
17struct C1 : C_Base<C_Base<0>::D{}> {} extern c1;
18struct C2 : C_Base<C_Const<0>::D{} extern c2;
Richard Smitha5230222015-03-27 01:37:43 +000019
20typedef struct { int a; void f(); struct X; } D;
21struct D::X { int dx; } extern dx;
Richard Smith9a71c992015-03-27 20:16:58 +000022inline int use_dx(D::X dx) { return dx.dx; }
Richard Smithd6aab592015-03-27 21:57:41 +000023
24template<typename T> int E(T t) { return t; }
25
26template<typename T> struct F {
27 int f();
28 template<typename U> int g();
Richard Smith82e57fb2015-05-19 00:49:29 +000029 static int n;
Richard Smithd6aab592015-03-27 21:57:41 +000030};
31template<typename T> int F<T>::f() { return 0; }
32template<typename T> template<typename U> int F<T>::g() { return 0; }
Richard Smith82e57fb2015-05-19 00:49:29 +000033template<typename T> int F<T>::n = 0;
Richard Smithf2b1eb92015-06-15 20:15:48 +000034//template<> template<typename U> int F<char>::g() { return 0; } // FIXME: Re-enable this once we support merging member specializations.
Richard Smithc7e6ff02015-05-18 20:36:47 +000035template<> struct F<void> { int h(); };
36inline int F<void>::h() { return 0; }
37template<typename T> struct F<T *> { int i(); };
38template<typename T> int F<T*>::i() { return 0; }
Richard Smithd9ba2242015-05-07 03:54:19 +000039
40namespace G {
41 enum A { a, b, c, d, e };
42 enum { f, g, h };
43 typedef enum { i, j } k;
44 typedef enum {} l;
45}
Richard Smithc7d48d12015-05-20 17:50:35 +000046
Richard Smithfd8b64e2015-05-20 18:24:21 +000047template<typename T = int, int N = 3, template<typename> class K = F> int H(int a = 1);
48template<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 +000049template<typename T = int, int N = 3, template<typename> class K = F> struct J {};
Richard Smith00be6d02015-06-11 03:05:39 +000050
51namespace NS {
52 struct A {};
Richard Smith0f192e82015-06-11 22:48:25 +000053 template<typename T> struct B : A {};
54 template<typename T> struct B<T*> : B<char> {};
55 template<> struct B<int> : B<int*> {};
Richard Smith00be6d02015-06-11 03:05:39 +000056 inline void f() {}
57}
Richard Smitha1431072015-06-12 01:32:13 +000058
59namespace StaticInline {
60 struct X {};
61 static inline void f(X);
62 static inline void g(X x) { f(x); }
63}
Richard Smith52933792015-06-16 21:57:05 +000064
65namespace FriendDefArg {
66 template<typename = int> struct A;
67 template<int = 0> struct B;
68 template<template<typename> class = A> struct C;
Richard Smithafe800c2015-06-17 22:13:23 +000069 template<typename = int, int = 0, template<typename> class = A> struct D {};
Richard Smith52933792015-06-16 21:57:05 +000070 template<typename U> struct Y {
71 template<typename> friend struct A;
72 template<int> friend struct B;
73 template<template<typename> class> friend struct C;
Richard Smithafe800c2015-06-17 22:13:23 +000074 template<typename, int, template<typename> class> friend struct D;
Richard Smith52933792015-06-16 21:57:05 +000075 };
76}