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