llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/136692.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2) 
- (modified) clang/test/AST/ByteCode/cxx11.cpp (+8) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 3e53f2a2c8557..7cba0e8a4da19 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2990,6 +2990,8 @@ bool Compiler<Emitter>::VisitCXXReinterpretCastExpr(
     if (PointeeToT && PointeeFromT) {
       if (isIntegralType(*PointeeFromT) && isIntegralType(*PointeeToT))
         Fatal = false;
+    } else {
+      Fatal = SubExpr->getType().getTypePtr() != E->getType().getTypePtr();
     }
 
     if (!this->emitInvalidCast(CastKind::Reinterpret, Fatal, E))
diff --git a/clang/test/AST/ByteCode/cxx11.cpp 
b/clang/test/AST/ByteCode/cxx11.cpp
index 23582e9ab556a..4c69517304ea7 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -185,3 +185,11 @@ namespace InitLinkToRVO {
   constexpr A make() { return A {}; }
   static_assert(make().z == 4, "");
 }
+
+namespace DynamicCast {
+  struct S { int x, y; } s;
+  constexpr S* sptr = &s;
+  struct Str {
+    int b : reinterpret_cast<S*>(sptr) == reinterpret_cast<S*>(sptr);
+  };
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/136692
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to