llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Where the private base is somewhere in the path, but not the target. --- Full diff: https://github.com/llvm/llvm-project/pull/217541.diff 1 Files Affected: - (modified) clang/test/AST/ByteCode/dynamic-cast.cpp (+14) ``````````diff diff --git a/clang/test/AST/ByteCode/dynamic-cast.cpp b/clang/test/AST/ByteCode/dynamic-cast.cpp index 83a745e271a28..22bc3b8b0b02b 100644 --- a/clang/test/AST/ByteCode/dynamic-cast.cpp +++ b/clang/test/AST/ByteCode/dynamic-cast.cpp @@ -204,6 +204,20 @@ namespace PrivateSibling { static_assert(dynamic_cast<E*>((B*)&g) == nullptr); } +namespace PrivateBase { + struct A {}; + struct B : public A {}; + struct C : private B{}; // both-note {{constrained by private inheritance here}} + struct D : public C{}; + constexpr bool foo() { + D d; + A *a = dynamic_cast<A*>(&d); // both-error {{cannot cast 'PrivateBase::D' to its private base class 'PrivateBase::A'}} + + return a != nullptr; + } + static_assert(foo()); +} + namespace Field { struct X { mutable int n = 0; `````````` </details> https://github.com/llvm/llvm-project/pull/217541 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
