blob: c151fbb9a5ba66edc308992bfd50230f00e1e461 [file] [log] [blame]
Douglas Gregor79c22782010-01-16 20:21:20 +00001// RUN: %clang_cc1 -verify %s
Andy Gibbs8e8fb3b2012-10-19 12:44:48 +00002// expected-no-diagnostics
Douglas Gregor79c22782010-01-16 20:21:20 +00003template<typename T>
4void f0() {
5 struct X;
6 typedef struct Y {
7 T (X::* f1())(int) { return 0; }
8 } Y2;
9
10 Y2 y = Y();
11}
12
13template void f0<int>();
Douglas Gregor26997fd2010-01-16 20:52:59 +000014
15// PR5764
16namespace PR5764 {
John McCall7002f4c2010-04-09 19:03:51 +000017 struct X {
Douglas Gregor26997fd2010-01-16 20:52:59 +000018 template <typename T>
19 void Bar() {
Douglas Gregor60406be2010-01-16 22:29:39 +000020 typedef T ValueType;
John McCall7002f4c2010-04-09 19:03:51 +000021 struct Y {
Douglas Gregor60406be2010-01-16 22:29:39 +000022 Y() { V = ValueType(); }
23
24 ValueType V;
Douglas Gregor26997fd2010-01-16 20:52:59 +000025 };
26
27 Y y;
28 }
29 };
30
31 void test(X x) {
32 x.Bar<int>();
33 }
34}
35
Chandler Carruth17e0f402010-02-15 22:12:26 +000036// Instantiation of local classes with virtual functions.
37namespace 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 Gregorebb1c562010-12-21 21:22:51 +000054
55namespace PR8801 {
56 template<typename T>
57 void foo() {
58 class X;
Douglas Gregorcfddf7b2010-12-21 21:40:41 +000059 typedef int (X::*pmf_type)();
Douglas Gregorebb1c562010-12-21 21:22:51 +000060 class X : public T { };
Douglas Gregorcfddf7b2010-12-21 21:40:41 +000061
62 pmf_type pmf = &T::foo;
Douglas Gregorebb1c562010-12-21 21:22:51 +000063 }
64
Douglas Gregorcfddf7b2010-12-21 21:40:41 +000065 struct Y { int foo(); };
Douglas Gregorebb1c562010-12-21 21:22:51 +000066
67 template void foo<Y>();
68}