int main(int argc, char* argv[]) { { false_value tr; tr = check<__is_abstract(A1)>::f(); } { false_value tr; tr = check<__is_abstract(A2)>::f(); } { true_value tr; tr = check<__is_abstract(A3)>::f(); } { true_value tr; tr = check<__is_abstract(A4)>::f(); } { false_value tr; tr = check<__is_abstract(A5)>::f(); } { false_value tr; tr = check<__is_abstract(A6)>::f(); } }
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 #ifndef __GXX_EXPERIMENTAL_CXX0X__ #define __CONCAT(__X, __Y) __CONCAT1(__X, __Y) #define __CONCAT1(__X, __Y) __X ## __Y #define static_assert(__b, __m) \ typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1] #endif class C { virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f'}} }; static_assert(__is_abstract(C), "C has a pure virtual function"); class D : C { }; static_assert(__is_abstract(D), "D inherits from an abstract class"); class E : D { virtual void f(); }; static_assert(!__is_abstract(E), "E inherits from an abstract class but implements f"); C *d = new C; // expected-error {{allocating an object of abstract class type 'C'}} C c; // expected-error {{variable type 'C' is an abstract class}} void t1(C c); // expected-error {{parameter type 'C' is an abstract class}}
bool tcp4 = __has_trivial_copy(void); bool tcp5 = __has_trivial_copy(const void); bool vde1 = __has_virtual_destructor(I); // { dg-error "incomplete type" } bool vde2 = __has_virtual_destructor(C[]); bool vde3 = __has_virtual_destructor(I[]); // { dg-error "incomplete type" } bool vde4 = __has_virtual_destructor(void); bool vde5 = __has_virtual_destructor(const void); bool tde1 = __has_trivial_destructor(I); // { dg-error "incomplete type" } bool tde2 = __has_trivial_destructor(C[]); bool tde3 = __has_trivial_destructor(I[]); // { dg-error "incomplete type" } bool tde4 = __has_trivial_destructor(void); bool tde5 = __has_trivial_destructor(const void); bool abs1 = __is_abstract(I); // { dg-error "incomplete type" } bool abs2 = __is_abstract(C[]); bool abs3 = __is_abstract(I[]); // { dg-error "incomplete type" } bool abs4 = __is_abstract(void); bool abs5 = __is_abstract(const void); bool pod1 = __is_pod(I); // { dg-error "incomplete type" } bool pod2 = __is_pod(C[]); bool pod3 = __is_pod(I[]); // { dg-error "incomplete type" } bool pod4 = __is_pod(void); bool pod5 = __is_pod(const void); bool emp1 = __is_empty(I); // { dg-error "incomplete type" } bool emp2 = __is_empty(C[]); bool emp3 = __is_empty(I[]); // { dg-error "incomplete type" } bool emp4 = __is_empty(void);
concept bool Abstract_type() { return __is_abstract(T); }
bool f() { return !!__is_abstract(T); }
bool f() { return !!__is_abstract(T); } }; template<typename T> class My2 { public: static const bool trait = __is_abstract(T); }; template<typename T> const bool My2<T>::trait; template<typename T, bool b = __is_abstract(T)> struct My3_help { static const bool trait = b; }; template<typename T, bool b> const bool My3_help<T, b>::trait; template<typename T> class My3 { public: bool f() { return My3_help<T>::trait; } };
float &fr = oil->f(i, l); } void test_ovl_bad() { Overloading<float, float> off; // expected-note{{in instantiation of template class 'Overloading<float, float>' requested here}} } template<typename T> class HasDestructor { public: virtual ~HasDestructor() = 0; }; int i = sizeof(HasDestructor<int>); // FIXME: forces instantiation, but // the code below should probably instantiate by itself. int abstract_destructor[__is_abstract(HasDestructor<int>)? 1 : -1]; template<typename T> class Constructors { public: Constructors(const T&); Constructors(const Constructors &other); }; void test_constructors() { Constructors<int> ci1(17); Constructors<int> ci2 = ci1; }