[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / derived.cpp
blob51e4db3b36f6628e6d356a4e6fc517cc9a0afc4c
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4 template<typename T> class vector2 {};
5 template<typename T> class vector : vector2<T> {};
7 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'}}
8 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'}}
10 void test() {
11 Foo2(vector2<int*>()); // expected-error{{no matching function for call to 'Foo2'}}
12 Foo(vector<int*>()); // expected-error{{no matching function for call to 'Foo'}}
15 namespace rdar13267210 {
16 template < typename T > class A {
17 BaseTy; // expected-error{{a type specifier is required for all declarations}}
20 template < typename T, int N > class C: A < T > {};
22 class B {
23 C<long, 16> ExternalDefinitions;
24 C<long, 64> &Record;
26 void AddSourceLocation(A<long> &R); // expected-note{{passing argument to parameter 'R' here}}
27 void AddTemplateKWAndArgsInfo() {
28 AddSourceLocation(Record); // expected-error{{non-const lvalue reference to type}}
33 namespace PR16292 {
34 class IncompleteClass; // expected-note{{forward declaration}}
35 class BaseClass {
36 IncompleteClass Foo; // expected-error{{field has incomplete type}}
38 template<class T> class DerivedClass : public BaseClass {};
39 void* p = new DerivedClass<void>;
42 namespace rdar14183893 {
43 class Typ { // expected-note {{not complete}}
44 Typ x; // expected-error {{incomplete type}}
47 template <unsigned C> class B : Typ {};
48 typedef B<0> TFP;
50 class A {
51 TFP m_p;
52 void Enable() { 0, A(); } // expected-warning {{left operand of comma operator has no effect}}