https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/217541

Where the private base is somewhere in the path, but not the target.

>From e441128e1092e2058f37f80f9468d18e41e4f26e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 20 Aug 2026 09:05:45 +0200
Subject: [PATCH] [clang][bytecode][NFC] Add another dynamic_cast test

Where the private base is somewhere in the path, but not the target.
---
 clang/test/AST/ByteCode/dynamic-cast.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to