Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Charles Li | e7cbb3e | 2015-11-17 20:25:05 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Fariborz Jahanian | c1fc3ec | 2009-07-01 19:21:19 +0000 | [diff] [blame] | 4 | |
| 5 | template<class X> struct A {}; |
| 6 | |
| 7 | template<class X> struct B : A<X> { |
| 8 | B() : A<X>() {} |
| 9 | }; |
| 10 | B<int> x; |
| 11 | |
| 12 | template<class X> struct B1 : A<X> { |
| 13 | typedef A<X> Base; |
| 14 | B1() : Base() {} |
| 15 | }; |
| 16 | B1<int> x1; |
| 17 | |
| 18 | |
| 19 | template<typename T> struct Tmpl { }; |
| 20 | |
| 21 | template<typename T> struct TmplB { }; |
| 22 | |
| 23 | struct TmplC : Tmpl<int> { |
| 24 | TmplC() : |
| 25 | Tmpl<int>(), |
| 26 | TmplB<int>() { } // expected-error {{type 'TmplB<int>' is not a direct or virtual base of 'TmplC'}} |
| 27 | }; |
| 28 | |
| 29 | |
| 30 | struct TmplD : Tmpl<char>, TmplB<char> { |
| 31 | TmplD(): |
| 32 | Tmpl<int>(), // expected-error {{type 'Tmpl<int>' is not a direct or virtual base of 'TmplD'}} |
| 33 | TmplB<char>() {} |
| 34 | }; |
| 35 | |
Douglas Gregor | 1c69bf0 | 2010-06-16 16:03:14 +0000 | [diff] [blame] | 36 | namespace PR7259 { |
| 37 | class Base { |
| 38 | public: |
| 39 | Base() {} |
| 40 | }; |
| 41 | |
| 42 | template <class ParentClass> |
| 43 | class Derived : public ParentClass { |
| 44 | public: |
| 45 | Derived() : Base() {} |
| 46 | }; |
| 47 | |
| 48 | class Final : public Derived<Base> { |
| 49 | }; |
| 50 | |
| 51 | int |
| 52 | main (void) |
| 53 | { |
Richard Smith | 69f90dc | 2012-01-05 04:12:21 +0000 | [diff] [blame] | 54 | Final final; |
Douglas Gregor | 1c69bf0 | 2010-06-16 16:03:14 +0000 | [diff] [blame] | 55 | return 0; |
| 56 | } |
| 57 | } |
Richard Smith | 60f2e1e | 2012-09-25 00:23:05 +0000 | [diff] [blame] | 58 | |
| 59 | namespace NonDependentError { |
Charles Li | e7cbb3e | 2015-11-17 20:25:05 +0000 | [diff] [blame] | 60 | struct Base { Base(int); }; // expected-note {{candidate constructor not viable}} |
| 61 | // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable}} |
| 62 | #if __cplusplus >= 201103L // C++11 or later |
| 63 | // expected-note@-3 {{candidate constructor (the implicit move constructor) not viable}} |
| 64 | #endif |
Richard Smith | 60f2e1e | 2012-09-25 00:23:05 +0000 | [diff] [blame] | 65 | |
| 66 | template<typename T> |
| 67 | struct Derived1 : Base { |
| 68 | Derived1() : Base(1, 2) {} // expected-error {{no matching constructor}} |
| 69 | }; |
| 70 | |
| 71 | template<typename T> |
| 72 | struct Derived2 : Base { |
| 73 | Derived2() : BaseClass(1) {} // expected-error {{does not name a non-static data member or base}} |
| 74 | }; |
| 75 | |
| 76 | Derived1<void> d1; |
| 77 | Derived2<void> d2; |
| 78 | } |