TestBadImplicitConversionCtor.cpp (1691B)
1 #define MOZ_IMPLICIT __attribute__((annotate("moz_implicit"))) 2 3 struct Foo { 4 Foo(int); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}} 5 Foo(int, char=0); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}} 6 Foo(...); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}} 7 template<class T> 8 Foo(float); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}} 9 Foo(int, unsigned); 10 Foo(Foo&); 11 Foo(const Foo&); 12 Foo(volatile Foo&); 13 Foo(const volatile Foo&); 14 Foo(Foo&&); 15 Foo(const Foo&&); 16 Foo(volatile Foo&&); 17 Foo(const volatile Foo&&); 18 }; 19 20 struct Bar { 21 explicit Bar(int); 22 explicit Bar(int, char=0); 23 explicit Bar(...); 24 }; 25 26 struct Baz { 27 MOZ_IMPLICIT Baz(int); 28 MOZ_IMPLICIT Baz(int, char=0); 29 MOZ_IMPLICIT Baz(...); 30 }; 31 32 struct Barn { 33 Barn(int) = delete; 34 Barn(int, char=0) = delete; 35 Barn(...) = delete; 36 }; 37 38 struct Abstract { 39 Abstract(int); 40 Abstract(int, char=0); 41 Abstract(...); 42 virtual void f() = 0; 43 }; 44 45 template<class T> 46 struct Template { 47 Template(int); // expected-error {{bad implicit conversion constructor for 'Template'}} expected-note {{consider adding the explicit keyword to the constructor}} 48 template<class U> 49 Template(float); // expected-error {{bad implicit conversion constructor for 'Template'}} expected-note {{consider adding the explicit keyword to the constructor}} 50 };