blob: e542507a2f7767a9251a1ed23fdaa11e142570fd [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor39a8de12009-02-25 19:37:18 +00002
3namespace N {
4 namespace M {
Chris Lattnerf4382f52009-04-14 22:17:06 +00005 template<typename T> struct Promote;
Douglas Gregor39a8de12009-02-25 19:37:18 +00006
7 template<> struct Promote<short> {
8 typedef int type;
9 };
10
11 template<> struct Promote<int> {
12 typedef int type;
13 };
14
15 template<> struct Promote<float> {
16 typedef double type;
17 };
18
19 Promote<short>::type *ret_intptr(int* ip) { return ip; }
20 Promote<int>::type *ret_intptr2(int* ip) { return ip; }
21 }
22
23 M::Promote<int>::type *ret_intptr3(int* ip) { return ip; }
Douglas Gregor732281d2010-06-14 22:07:54 +000024 M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' refers to a non-dependent template name; accepted as a C++0x extension}}
Douglas Gregor39a8de12009-02-25 19:37:18 +000025}
26
27N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; }
28::N::M::Promote<int>::type *ret_intptr6(int* ip) { return ip; }
29
30
Douglas Gregor7bb87fc2009-11-11 16:39:34 +000031N::M::template; // expected-error{{expected unqualified-id}}
32N::M::template Promote; // expected-error{{expected unqualified-id}}
Douglas Gregor39a8de12009-02-25 19:37:18 +000033
34namespace N {
35 template<typename T> struct A;
36
37 template<>
38 struct A<int> {
39 struct X;
40 };
Douglas Gregorc45c2322009-03-31 00:43:58 +000041
42 struct B;
Douglas Gregor39a8de12009-02-25 19:37:18 +000043}
44
45struct ::N::A<int>::X {
46 int foo;
47};
Douglas Gregorc45c2322009-03-31 00:43:58 +000048
Douglas Gregorc45c2322009-03-31 00:43:58 +000049template<typename T>
50struct TestA {
Douglas Gregor7bb87fc2009-11-11 16:39:34 +000051 typedef typename N::template B<T>::type type; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \
Douglas Gregor7bb87fc2009-11-11 16:39:34 +000052 // expected-error{{expected member name}}
Douglas Gregorc45c2322009-03-31 00:43:58 +000053};
John McCall63b43852010-04-29 23:50:39 +000054
55// Reduced from a Boost failure.
56namespace test1 {
57 template <class T> struct pair {
58 T x;
59 T y;
60
61 static T pair<T>::* const mem_array[2];
62 };
63
64 template <class T>
65 T pair<T>::* const pair<T>::mem_array[2] = { &pair<T>::x, &pair<T>::y };
66}
Douglas Gregor00b4b032010-05-14 04:53:42 +000067
68typedef int T;
69namespace N1 {
70 template<typename T> T f0();
71}
72
73template<typename T> T N1::f0() { }