Index: libcxx/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp =================================================================== --- libcxx/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp +++ libcxx/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp @@ -14,6 +14,15 @@ #include "test_macros.h" +// Clang before v9 and apple-clang up to and including v10 do not +// report that unions are never base classes - nor can they have bases. +// See https://reviews.llvm.org/D61858 +#if (defined(TEST_COMPILER_APPLE_CLANG) && TEST_APPLE_CLANG_VER <= 1000) +#define TEST_NO_INCOMPLETE_UNIONS +#elif (defined(TEST_COMPILER_CLANG) && TEST_CLANG_VER < 900) +#define TEST_NO_INCOMPLETE_UNIONS +#endif + template void test_is_base_of() { @@ -39,6 +48,10 @@ struct B1 : B {}; struct B2 : B {}; struct D : private B1, private B2 {}; +union U0; +union U1 {}; +struct I0; +struct I1 {}; int main(int, char**) { @@ -54,5 +67,61 @@ test_is_not_base_of(); test_is_not_base_of(); +#ifndef TEST_NO_INCOMPLETE_UNIONS +// A union is never the base class of anything (including incomplete types) + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + +// A union never has base classes (including incomplete types) + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); +#endif + +// A scalar is never the base class of anything (including incomplete types) + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + +// A scalar never has base classes (including incomplete types) + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + return 0; }