llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Jess Ding (jessding) <details> <summary>Changes</summary> Adding a test to document CD4 resolution of [DR 242](https://cplusplus.github.io/CWG/issues/242.html) (currently availability in clang is [marked as unknown](https://clang.llvm.org/cxx_dr_status.html)). I used Claude Code to understand more about clang/the tests/the repo, but wrote the test code myself. [description WIP, need to add in responses to the below. will un-draft this PR after I've gone through the policies.] --- Full diff: https://github.com/llvm/llvm-project/pull/201441.diff 1 Files Affected: - (modified) clang/test/CXX/drs/cwg2xx.cpp (+31) ``````````diff diff --git a/clang/test/CXX/drs/cwg2xx.cpp b/clang/test/CXX/drs/cwg2xx.cpp index f81ab02e7d748..2ca9a84d0a03a 100644 --- a/clang/test/CXX/drs/cwg2xx.cpp +++ b/clang/test/CXX/drs/cwg2xx.cpp @@ -695,6 +695,37 @@ namespace cwg241 { // cwg241: 9 } } // namespace cwg241 +namespace cwg242 { // cwg242: yes + struct A {}; + struct I1 : A {}; + struct I2 : A {}; + struct D : I1, I2 {}; + + A *upcast(D *p) { + return (A *)(p); + /* expected-error@-1 + {{ambiguous conversion from derived class 'D' to base class 'A': + struct cwg242::D -> I1 -> A + struct cwg242::D -> I2 -> A}}*/ + } + + D *downcast(A *p) { + return (D *)(p); + /* expected-error@-1 + {{ambiguous cast from base 'cwg242::A' to derived 'cwg242::D': + A -> I1 -> struct cwg242::D + A -> I2 -> struct cwg242::D}}*/ + } + + struct V {}; + struct B : virtual V {}; + + B *virt_downcast(V *p) { + return (B *)(p); + // expected-error@-1 {{cannot cast 'cwg242::V *' to 'B *' via virtual base 'cwg242::V'}} + } +} // namespace cwg242 + namespace cwg243 { // cwg243: 2.8 struct B; struct A { `````````` </details> https://github.com/llvm/llvm-project/pull/201441 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
