https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/185370

>From 0ef172c1b8c84a13ede90889c0962829e57b35bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Mon, 9 Mar 2026 09:03:03 +0100
Subject: [PATCH] [clang][bytecode] Check memberpointer exprs for errors

---
 clang/lib/AST/ByteCode/Compiler.cpp        |  7 +++++++
 clang/test/AST/ByteCode/memberpointers.cpp | 15 +++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 6d8b84a83a4ad..42d137f097760 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -269,6 +269,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
   }
 
   case CK_DerivedToBaseMemberPointer: {
+    if (CE->containsErrors())
+      return false;
     assert(classifyPrim(CE) == PT_MemberPtr);
     assert(classifyPrim(SubExpr) == PT_MemberPtr);
 
@@ -291,6 +293,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
   }
 
   case CK_BaseToDerivedMemberPointer: {
+    if (CE->containsErrors())
+      return false;
     assert(classifyPrim(CE) == PT_MemberPtr);
     assert(classifyPrim(SubExpr) == PT_MemberPtr);
 
@@ -1106,6 +1110,9 @@ bool Compiler<Emitter>::VisitBinaryOperator(const 
BinaryOperator *BO) {
     return this->VisitFixedPointBinOp(BO);
 
   if (BO->isPtrMemOp()) {
+    if (BO->containsErrors())
+      return false;
+
     if (!this->visit(LHS))
       return false;
 
diff --git a/clang/test/AST/ByteCode/memberpointers.cpp 
b/clang/test/AST/ByteCode/memberpointers.cpp
index fb489a1961434..e2a154914c83b 100644
--- a/clang/test/AST/ByteCode/memberpointers.cpp
+++ b/clang/test/AST/ByteCode/memberpointers.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c++14 -fexperimental-new-constant-interpreter 
-verify=expected,both %s
 // RUN: %clang_cc1 -std=c++23 -fexperimental-new-constant-interpreter 
-verify=expected,both %s
-// RUN: %clang_cc1 -std=c++14 -verify=ref,both %s
-// RUN: %clang_cc1 -std=c++23 -verify=ref,both %s
+// RUN: %clang_cc1 -std=c++14                                         
-verify=ref,both      %s
+// RUN: %clang_cc1 -std=c++23                                         
-verify=ref,both      %s
 
 namespace MemberPointers {
   struct A {
@@ -303,3 +303,14 @@ namespace Equality {
   constexpr int (T<17>::*deepm) = (int(T<10>::*))&T<30>::m;
   static_assert(deepm == &T<50>::m, "");
 }
+
+namespace Errors {
+#if __cplusplus >= 202302L
+  constexpr bool test1() {
+    X s; // both-error {{unknown type name}}
+    s.*bar(); // both-error {{use of undeclared identifier}}
+    return true;
+  }
+  static_assert(test1(), ""); // both-error {{not an integral constant 
expression}}
+#endif
+}

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

Reply via email to