// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { int x; }; class Base { public: virtual void f(); }; class Derived : public Base { }; struct ConvertibleToInt { operator int() const; }; struct Constructible { Constructible(int, float); }; // --------------------------------------------------------------------- // C-style casts // --------------------------------------------------------------------- template struct CStyleCast0 { void f(T t) { (void)((U)t); // expected-error{{C-style cast from 'A' to 'int' is not allowed}} } }; template struct CStyleCast0; template struct CStyleCast0; // expected-note{{instantiation}} // --------------------------------------------------------------------- // static_cast // --------------------------------------------------------------------- template struct StaticCast0 { void f(T t) { (void)static_cast(t); // expected-error{{static_cast from 'int' to 'A' is not allowed}} } }; template struct StaticCast0; template struct StaticCast0; template struct StaticCast0; // expected-note{{instantiation}} // --------------------------------------------------------------------- // dynamic_cast // --------------------------------------------------------------------- template struct DynamicCast0 { void f(T t) { (void)dynamic_cast(t); // expected-error{{not a reference or pointer}} } }; template struct DynamicCast0; template struct DynamicCast0; // expected-note{{instantiation}} // --------------------------------------------------------------------- // reinterpret_cast // --------------------------------------------------------------------- template struct ReinterpretCast0 { void f(T t) { (void)reinterpret_cast(t); // expected-error{{constness}} } }; template struct ReinterpretCast0; template struct ReinterpretCast0; // expected-note{{instantiation}} // --------------------------------------------------------------------- // const_cast // --------------------------------------------------------------------- template struct ConstCast0 { void f(T t) { (void)const_cast(t); // expected-error{{not allowed}} } }; template struct ConstCast0; template struct ConstCast0; // expected-note{{instantiation}} // --------------------------------------------------------------------- // C++ functional cast // --------------------------------------------------------------------- template struct FunctionalCast1 { void f(T t) { (void)U(t); // expected-error{{functional-style cast from 'A' to 'int' is not allowed}} } }; template struct FunctionalCast1; template struct FunctionalCast1; // expected-note{{instantiation}} // Generates temporaries, which we cannot handle yet. template struct FunctionalCast2 { void f() { (void)Constructible(N, M); } }; template struct FunctionalCast2<1, 3>; // --------------------------------------------------------------------- // implicit casting // --------------------------------------------------------------------- template struct Derived2 : public Base { }; void test_derived_to_base(Base *&bp, Derived2 *dp) { bp = dp; }