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