blob: 670c400ae3b266b63abc9ac3ca9f2663fe903056 [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 Smith5327b892015-07-01 19:32:54 +000013template<> inline void B::f<int>() {}
Richard Smithbe3980b2015-03-27 00:41:57 +000014
15// Check that base-specifiers are correctly disambiguated.
16template<int N> struct C_Base { struct D { constexpr operator int() const { return 0; } }; };
17const int C_Const = 0;
18struct C1 : C_Base<C_Base<0>::D{}> {} extern c1;
19struct C2 : C_Base<C_Const<0>::D{} extern c2;
Richard Smitha5230222015-03-27 01:37:43 +000020
21typedef struct { int a; void f(); struct X; } D;
22struct D::X { int dx; } extern dx;
Richard Smith9a71c992015-03-27 20:16:58 +000023inline int use_dx(D::X dx) { return dx.dx; }
Richard Smithd6aab592015-03-27 21:57:41 +000024
25template<typename T> int E(T t) { return t; }
26
27template<typename T> struct F {
28 int f();
29 template<typename U> int g();
Richard Smith82e57fb2015-05-19 00:49:29 +000030 static int n;
Richard Smithd6aab592015-03-27 21:57:41 +000031};
32template<typename T> int F<T>::f() { return 0; }
33template<typename T> template<typename U> int F<T>::g() { return 0; }
Richard Smith82e57fb2015-05-19 00:49:29 +000034template<typename T> int F<T>::n = 0;
Richard Smith5327b892015-07-01 19:32:54 +000035template<> inline int F<char>::f() { return 0; }
36template<> template<typename U> int F<char>::g() { return 0; }
Richard Smithc7e6ff02015-05-18 20:36:47 +000037template<> struct F<void> { int h(); };
38inline int F<void>::h() { return 0; }
39template<typename T> struct F<T *> { int i(); };
40template<typename T> int F<T*>::i() { return 0; }
Richard Smithd9ba2242015-05-07 03:54:19 +000041
42namespace G {
43 enum A { a, b, c, d, e };
44 enum { f, g, h };
45 typedef enum { i, j } k;
46 typedef enum {} l;
47}
Richard Smithc7d48d12015-05-20 17:50:35 +000048
Richard Smithfd8b64e2015-05-20 18:24:21 +000049template<typename T = int, int N = 3, template<typename> class K = F> int H(int a = 1);
50template<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 +000051template<typename T = int, int N = 3, template<typename> class K = F> struct J {};
Richard Smith00be6d02015-06-11 03:05:39 +000052
53namespace NS {
54 struct A {};
Richard Smith0f192e82015-06-11 22:48:25 +000055 template<typename T> struct B : A {};
56 template<typename T> struct B<T*> : B<char> {};
57 template<> struct B<int> : B<int*> {};
Richard Smith00be6d02015-06-11 03:05:39 +000058 inline void f() {}
59}
Richard Smitha1431072015-06-12 01:32:13 +000060
61namespace StaticInline {
62 struct X {};
63 static inline void f(X);
64 static inline void g(X x) { f(x); }
65}
Richard Smith52933792015-06-16 21:57:05 +000066
67namespace FriendDefArg {
68 template<typename = int> struct A;
69 template<int = 0> struct B;
70 template<template<typename> class = A> struct C;
Richard Smithafe800c2015-06-17 22:13:23 +000071 template<typename = int, int = 0, template<typename> class = A> struct D {};
Richard Smith52933792015-06-16 21:57:05 +000072 template<typename U> struct Y {
73 template<typename> friend struct A;
74 template<int> friend struct B;
75 template<template<typename> class> friend struct C;
Richard Smithafe800c2015-06-17 22:13:23 +000076 template<typename, int, template<typename> class> friend struct D;
Richard Smith52933792015-06-16 21:57:05 +000077 };
78}
Richard Smith76553812015-07-01 07:24:18 +000079
80namespace SeparateInline {
81 inline void f();
82 void f() {}
83 constexpr int g() { return 0; }
84}
Richard Smith04c6c1f2015-07-01 18:56:50 +000085
86namespace TrailingAttributes {
87 template<typename T> struct X {} __attribute__((aligned(8)));
88}
Richard Smithda6c2342015-07-01 23:19:58 +000089
90namespace MergeFunctionTemplateSpecializations {
91 template<typename T> T f();
92 template<typename T> struct X {
93 template<typename U> using Q = decltype(f<T>() + U());
94 };
95 using xiq = X<int>::Q<int>;
96}
Richard Smithb1d8ea42015-07-08 21:49:31 +000097
98enum ScopedEnum : int;
99enum ScopedEnum : int { a, b, c };
Richard Smith826711d2015-07-29 23:38:25 +0000100
101namespace RedeclDifferentDeclKind {
102 struct X {};
103 typedef X X;
104 using RedeclDifferentDeclKind::X;
105}
Richard Smith8cbd8952015-08-04 02:05:09 +0000106
107namespace Anon {
108 struct X {
109 union {
110 int n;
111 };
112 };
113}