xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/derived.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3f4a2713aSLionel Sambuc 
4f4a2713aSLionel Sambuc template<typename T> class vector2 {};
5f4a2713aSLionel Sambuc template<typename T> class vector : vector2<T> {};
6f4a2713aSLionel Sambuc 
Foo2(vector2<const T * > V)7*0a6a1f1dSLionel Sambuc template<typename T> void Foo2(vector2<const T*> V) {}  // expected-note{{candidate template ignored: can't deduce a type for 'T' that would make 'const T' equal 'int'}}
Foo(vector<const T * > V)8*0a6a1f1dSLionel Sambuc template<typename T> void Foo(vector<const T*> V) {} // expected-note {{candidate template ignored: can't deduce a type for 'T' that would make 'const T' equal 'int'}}
9f4a2713aSLionel Sambuc 
test()10f4a2713aSLionel Sambuc void test() {
11f4a2713aSLionel Sambuc   Foo2(vector2<int*>());  // expected-error{{no matching function for call to 'Foo2'}}
12f4a2713aSLionel Sambuc   Foo(vector<int*>());  // expected-error{{no matching function for call to 'Foo'}}
13f4a2713aSLionel Sambuc }
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc namespace rdar13267210 {
16f4a2713aSLionel Sambuc   template < typename T > class A {
17f4a2713aSLionel Sambuc     BaseTy; // expected-error{{C++ requires a type specifier for all declarations}}
18f4a2713aSLionel Sambuc   };
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc   template < typename T, int N > class C: A < T > {};
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc   class B {
23f4a2713aSLionel Sambuc     C<long, 16> ExternalDefinitions;
24f4a2713aSLionel Sambuc     C<long, 64> &Record;
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc     void AddSourceLocation(A<long> &R); // expected-note{{passing argument to parameter 'R' here}}
AddTemplateKWAndArgsInfo()27f4a2713aSLionel Sambuc     void AddTemplateKWAndArgsInfo() {
28f4a2713aSLionel Sambuc       AddSourceLocation(Record); // expected-error{{non-const lvalue reference to type}}
29f4a2713aSLionel Sambuc     }
30f4a2713aSLionel Sambuc   };
31f4a2713aSLionel Sambuc }
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc namespace PR16292 {
34f4a2713aSLionel Sambuc   class IncompleteClass;  // expected-note{{forward declaration}}
35f4a2713aSLionel Sambuc   class BaseClass {
36f4a2713aSLionel Sambuc     IncompleteClass Foo;  // expected-error{{field has incomplete type}}
37f4a2713aSLionel Sambuc   };
38f4a2713aSLionel Sambuc   template<class T> class DerivedClass : public BaseClass {};
39f4a2713aSLionel Sambuc   void* p = new DerivedClass<void>;
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc namespace rdar14183893 {
43f4a2713aSLionel Sambuc   class Typ { // expected-note {{not complete}}
44f4a2713aSLionel Sambuc     Typ x; // expected-error {{incomplete type}}
45f4a2713aSLionel Sambuc   };
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc   template <unsigned  C> class B :  Typ {};
48f4a2713aSLionel Sambuc   typedef B<0> TFP;
49f4a2713aSLionel Sambuc 
50f4a2713aSLionel Sambuc   class A {
51f4a2713aSLionel Sambuc     TFP m_p;
Enable()52f4a2713aSLionel Sambuc     void Enable() { 0, A(); } // expected-warning {{unused}}
53f4a2713aSLionel Sambuc   };
54f4a2713aSLionel Sambuc }
55