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