2015-08-21 01:58:07 +08:00
// RUN: %python %S/check_clang_tidy.py %s misc-undelegated-constructor %t
2014-07-31 17:58:52 +08:00
struct Ctor ;
Ctor foo ( ) ;
struct Ctor {
Ctor ( ) ;
Ctor ( int ) ;
Ctor ( int , int ) ;
Ctor ( Ctor * i ) {
Ctor ( ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead [misc-undelegated-constructor]
2014-07-31 17:58:52 +08:00
Ctor ( 0 ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
Ctor ( 1 , 2 ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
foo ( ) ;
}
} ;
Ctor : : Ctor ( ) {
Ctor ( 1 ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
}
Ctor : : Ctor ( int i ) : Ctor ( i , 1 ) { } // properly delegated.
struct Dtor {
Dtor ( ) ;
Dtor ( int ) ;
Dtor ( int , int ) ;
Dtor ( Ctor * i ) {
Dtor ( ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
Dtor ( 0 ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
Dtor ( 1 , 2 ) ;
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
}
~ Dtor ( ) ;
} ;
struct Base { } ;
struct Derived : public Base {
Derived ( ) { Base ( ) ; }
2014-10-26 10:58:07 +08:00
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: did you intend to call a delegated constructor?
2014-07-31 17:58:52 +08:00
} ;
template < typename T >
struct TDerived : public Base {
TDerived ( ) { Base ( ) ; }
} ;
TDerived < int > t ;