Douglas Gregor | 79c2278 | 2010-01-16 20:21:20 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify %s |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 2 | // expected-no-diagnostics |
Douglas Gregor | 79c2278 | 2010-01-16 20:21:20 +0000 | [diff] [blame] | 3 | template<typename T> |
| 4 | void f0() { |
| 5 | struct X; |
| 6 | typedef struct Y { |
| 7 | T (X::* f1())(int) { return 0; } |
| 8 | } Y2; |
| 9 | |
| 10 | Y2 y = Y(); |
| 11 | } |
| 12 | |
| 13 | template void f0<int>(); |
Douglas Gregor | 26997fd | 2010-01-16 20:52:59 +0000 | [diff] [blame] | 14 | |
| 15 | // PR5764 |
| 16 | namespace PR5764 { |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 17 | struct X { |
Douglas Gregor | 26997fd | 2010-01-16 20:52:59 +0000 | [diff] [blame] | 18 | template <typename T> |
| 19 | void Bar() { |
Douglas Gregor | 60406be | 2010-01-16 22:29:39 +0000 | [diff] [blame] | 20 | typedef T ValueType; |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 21 | struct Y { |
Douglas Gregor | 60406be | 2010-01-16 22:29:39 +0000 | [diff] [blame] | 22 | Y() { V = ValueType(); } |
| 23 | |
| 24 | ValueType V; |
Douglas Gregor | 26997fd | 2010-01-16 20:52:59 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | Y y; |
| 28 | } |
| 29 | }; |
| 30 | |
| 31 | void test(X x) { |
| 32 | x.Bar<int>(); |
| 33 | } |
| 34 | } |
| 35 | |
Chandler Carruth | 17e0f40 | 2010-02-15 22:12:26 +0000 | [diff] [blame] | 36 | // Instantiation of local classes with virtual functions. |
| 37 | namespace local_class_with_virtual_functions { |
| 38 | template <typename T> struct X { }; |
| 39 | template <typename T> struct Y { }; |
| 40 | |
| 41 | template <typename T> |
| 42 | void f() { |
| 43 | struct Z : public X<Y<T>*> { |
| 44 | virtual void g(Y<T>* y) { } |
| 45 | void g2(int x) {(void)x;} |
| 46 | }; |
| 47 | Z z; |
| 48 | (void)z; |
| 49 | } |
| 50 | |
| 51 | struct S { }; |
| 52 | void test() { f<S>(); } |
| 53 | } |
Douglas Gregor | ebb1c56 | 2010-12-21 21:22:51 +0000 | [diff] [blame] | 54 | |
| 55 | namespace PR8801 { |
| 56 | template<typename T> |
| 57 | void foo() { |
| 58 | class X; |
Douglas Gregor | cfddf7b | 2010-12-21 21:40:41 +0000 | [diff] [blame] | 59 | typedef int (X::*pmf_type)(); |
Douglas Gregor | ebb1c56 | 2010-12-21 21:22:51 +0000 | [diff] [blame] | 60 | class X : public T { }; |
Douglas Gregor | cfddf7b | 2010-12-21 21:40:41 +0000 | [diff] [blame] | 61 | |
| 62 | pmf_type pmf = &T::foo; |
Douglas Gregor | ebb1c56 | 2010-12-21 21:22:51 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Douglas Gregor | cfddf7b | 2010-12-21 21:40:41 +0000 | [diff] [blame] | 65 | struct Y { int foo(); }; |
Douglas Gregor | ebb1c56 | 2010-12-21 21:22:51 +0000 | [diff] [blame] | 66 | |
| 67 | template void foo<Y>(); |
| 68 | } |