Author: Timm Baeder
Date: 2026-08-20T10:24:31+02:00
New Revision: 1b3f575805e7ea963688ed15f1dc3785012328fe

URL: 
https://github.com/llvm/llvm-project/commit/1b3f575805e7ea963688ed15f1dc3785012328fe
DIFF: 
https://github.com/llvm/llvm-project/commit/1b3f575805e7ea963688ed15f1dc3785012328fe.diff

LOG: [clang][bytecode][NFC] Add another dynamic_cast test (#217541)

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

Added: 
    

Modified: 
    clang/test/AST/ByteCode/dynamic-cast.cpp

Removed: 
    


################################################################################
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