[clang] 7863646 - [clang][Interp] DerivedToBase casts

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 10 23:38:32 PST 2022


Author: Timm Bäder
Date: 2022-11-11T08:38:06+01:00
New Revision: 7863646fd206952492b9abdbf690be2c4198d728

URL: https://github.com/llvm/llvm-project/commit/7863646fd206952492b9abdbf690be2c4198d728
DIFF: https://github.com/llvm/llvm-project/commit/7863646fd206952492b9abdbf690be2c4198d728.diff

LOG: [clang][Interp] DerivedToBase casts

Differential Revision: https://reviews.llvm.org/D137545

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/test/AST/Interp/records.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 91b9809861d8b..b01c428060da5 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -107,7 +107,8 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
         });
   }
 
-  case CK_UncheckedDerivedToBase: {
+  case CK_UncheckedDerivedToBase:
+  case CK_DerivedToBase: {
     if (!this->visit(SubExpr))
       return false;
 

diff  --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp
index d8ac72319c0a2..f49a6736c135b 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -245,6 +245,8 @@ namespace MI {
   static_assert(c.a == 10, "");
   static_assert(c.b == 20, "");
 
+  constexpr const A *aPointer = &c;
+  constexpr const B *bPointer = &c;
 
   class D : private A, private B {
     public:


        


More information about the cfe-commits mailing list