llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We already do this similarly for CXXReinterpretCastExprs, except in that case 
we try harder to make things work.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3) 
- (modified) clang/test/AST/ByteCode/cxx11.cpp (+4) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index b68576158decc..b39736587034d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -779,6 +779,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
     // a diagnostic if appropriate.
     return this->delegate(SubExpr);
 
+  case CK_LValueBitCast:
+    return this->emitInvalidCast(CastKind::ReinterpretLike, /*Fatal=*/true, 
CE);
+
   default:
     return this->emitInvalid(CE);
   }
diff --git a/clang/test/AST/ByteCode/cxx11.cpp 
b/clang/test/AST/ByteCode/cxx11.cpp
index 9a61321f67a40..e1fb5948b7708 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -33,6 +33,10 @@ constexpr int b = b; // both-error {{must be initialized by 
a constant expressio
                                                       // both-note {{declared 
here}}
 
 
+  void func();
+  constexpr int (&fp4)() = (int(&)())func; // both-error {{constant 
expression}} \
+                                           // both-note {{reinterpret_cast}}
+
 struct S {
   int m;
 };

``````````

</details>


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

Reply via email to