Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 1 | struct A { int a_member; }; |
Richard Smith | 9a71c99 | 2015-03-27 20:16:58 +0000 | [diff] [blame] | 2 | inline int use_a(A a) { return a.a_member; } |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 3 | |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 4 | class B { |
| 5 | struct Inner1 {}; |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 6 | public: |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 7 | struct Inner2; |
Richard Smith | 6dc8ae1 | 2015-08-17 20:24:17 +0000 | [diff] [blame] | 8 | struct Inner3; |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 9 | template<typename T> void f(); |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 10 | }; |
Richard Smith | 6dc8ae1 | 2015-08-17 20:24:17 +0000 | [diff] [blame] | 11 | struct BFriend { |
| 12 | friend class B::Inner3; |
| 13 | private: |
| 14 | struct Inner3Base {}; |
| 15 | }; |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 16 | // Check that lookup and access checks are performed in the right context. |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 17 | struct B::Inner2 : Inner1 {}; |
Richard Smith | 6dc8ae1 | 2015-08-17 20:24:17 +0000 | [diff] [blame] | 18 | struct B::Inner3 : BFriend::Inner3Base {}; |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 19 | template<typename T> void B::f() {} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 20 | template<> inline void B::f<int>() {} |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 21 | |
| 22 | // Check that base-specifiers are correctly disambiguated. |
| 23 | template<int N> struct C_Base { struct D { constexpr operator int() const { return 0; } }; }; |
| 24 | const int C_Const = 0; |
| 25 | struct C1 : C_Base<C_Base<0>::D{}> {} extern c1; |
| 26 | struct C2 : C_Base<C_Const<0>::D{} extern c2; |
Richard Smith | a523022 | 2015-03-27 01:37:43 +0000 | [diff] [blame] | 27 | |
| 28 | typedef struct { int a; void f(); struct X; } D; |
| 29 | struct D::X { int dx; } extern dx; |
Richard Smith | 9a71c99 | 2015-03-27 20:16:58 +0000 | [diff] [blame] | 30 | inline int use_dx(D::X dx) { return dx.dx; } |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 31 | |
| 32 | template<typename T> int E(T t) { return t; } |
| 33 | |
| 34 | template<typename T> struct F { |
| 35 | int f(); |
| 36 | template<typename U> int g(); |
Richard Smith | 82e57fb | 2015-05-19 00:49:29 +0000 | [diff] [blame] | 37 | static int n; |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 38 | }; |
| 39 | template<typename T> int F<T>::f() { return 0; } |
| 40 | template<typename T> template<typename U> int F<T>::g() { return 0; } |
Richard Smith | 82e57fb | 2015-05-19 00:49:29 +0000 | [diff] [blame] | 41 | template<typename T> int F<T>::n = 0; |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 42 | template<> inline int F<char>::f() { return 0; } |
| 43 | template<> template<typename U> int F<char>::g() { return 0; } |
Richard Smith | c7e6ff0 | 2015-05-18 20:36:47 +0000 | [diff] [blame] | 44 | template<> struct F<void> { int h(); }; |
| 45 | inline int F<void>::h() { return 0; } |
| 46 | template<typename T> struct F<T *> { int i(); }; |
| 47 | template<typename T> int F<T*>::i() { return 0; } |
Richard Smith | d9ba224 | 2015-05-07 03:54:19 +0000 | [diff] [blame] | 48 | |
| 49 | namespace 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 Smith | c7d48d1 | 2015-05-20 17:50:35 +0000 | [diff] [blame] | 55 | |
Richard Smith | fd8b64e | 2015-05-20 18:24:21 +0000 | [diff] [blame] | 56 | template<typename T = int, int N = 3, template<typename> class K = F> int H(int a = 1); |
| 57 | template<typename T = int, int N = 3, template<typename> class K = F> using I = decltype(H<T, N, K>()); |
Richard Smith | c785276 | 2015-06-11 23:46:11 +0000 | [diff] [blame] | 58 | template<typename T = int, int N = 3, template<typename> class K = F> struct J {}; |
Richard Smith | 00be6d0 | 2015-06-11 03:05:39 +0000 | [diff] [blame] | 59 | |
| 60 | namespace NS { |
| 61 | struct A {}; |
Richard Smith | 0f192e8 | 2015-06-11 22:48:25 +0000 | [diff] [blame] | 62 | template<typename T> struct B : A {}; |
| 63 | template<typename T> struct B<T*> : B<char> {}; |
| 64 | template<> struct B<int> : B<int*> {}; |
Richard Smith | 00be6d0 | 2015-06-11 03:05:39 +0000 | [diff] [blame] | 65 | inline void f() {} |
| 66 | } |
Richard Smith | a143107 | 2015-06-12 01:32:13 +0000 | [diff] [blame] | 67 | |
| 68 | namespace StaticInline { |
| 69 | struct X {}; |
| 70 | static inline void f(X); |
| 71 | static inline void g(X x) { f(x); } |
| 72 | } |
Richard Smith | 5293379 | 2015-06-16 21:57:05 +0000 | [diff] [blame] | 73 | |
| 74 | namespace FriendDefArg { |
| 75 | template<typename = int> struct A; |
| 76 | template<int = 0> struct B; |
| 77 | template<template<typename> class = A> struct C; |
Richard Smith | afe800c | 2015-06-17 22:13:23 +0000 | [diff] [blame] | 78 | template<typename = int, int = 0, template<typename> class = A> struct D {}; |
Richard Smith | 5293379 | 2015-06-16 21:57:05 +0000 | [diff] [blame] | 79 | 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 Smith | afe800c | 2015-06-17 22:13:23 +0000 | [diff] [blame] | 83 | template<typename, int, template<typename> class> friend struct D; |
Richard Smith | 5293379 | 2015-06-16 21:57:05 +0000 | [diff] [blame] | 84 | }; |
| 85 | } |
Richard Smith | 7655381 | 2015-07-01 07:24:18 +0000 | [diff] [blame] | 86 | |
| 87 | namespace SeparateInline { |
| 88 | inline void f(); |
| 89 | void f() {} |
| 90 | constexpr int g() { return 0; } |
| 91 | } |
Richard Smith | 04c6c1f | 2015-07-01 18:56:50 +0000 | [diff] [blame] | 92 | |
| 93 | namespace TrailingAttributes { |
| 94 | template<typename T> struct X {} __attribute__((aligned(8))); |
| 95 | } |
Richard Smith | da6c234 | 2015-07-01 23:19:58 +0000 | [diff] [blame] | 96 | |
| 97 | namespace 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 Smith | b1d8ea4 | 2015-07-08 21:49:31 +0000 | [diff] [blame] | 104 | |
| 105 | enum ScopedEnum : int; |
| 106 | enum ScopedEnum : int { a, b, c }; |
Richard Smith | 826711d | 2015-07-29 23:38:25 +0000 | [diff] [blame] | 107 | |
| 108 | namespace RedeclDifferentDeclKind { |
| 109 | struct X {}; |
| 110 | typedef X X; |
| 111 | using RedeclDifferentDeclKind::X; |
| 112 | } |
Richard Smith | 8cbd895 | 2015-08-04 02:05:09 +0000 | [diff] [blame] | 113 | |
| 114 | namespace Anon { |
| 115 | struct X { |
| 116 | union { |
| 117 | int n; |
| 118 | }; |
| 119 | }; |
| 120 | } |
Richard Smith | 2bb3c34 | 2015-08-09 01:05:31 +0000 | [diff] [blame] | 121 | |
| 122 | namespace 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 Smith | 84824ed | 2015-12-11 22:39:52 +0000 | [diff] [blame] | 134 | |
| 135 | struct MemberClassTemplate { |
| 136 | template<typename T> struct A; |
| 137 | }; |
| 138 | template<typename T> struct MemberClassTemplate::A {}; |
| 139 | template<typename T> struct MemberClassTemplate::A<T*> {}; |
| 140 | template<> struct MemberClassTemplate::A<int> {}; |