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

>From 5a8f100c405f0ca3863b422c06193a249426abd4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Mon, 26 Oct 2026 07:39:40 +0100
Subject: [PATCH] [clang][bytecode] Emit has_lvalue for opaque pointers

They always have a base and need the note emitted so
HasConstantInitialization of the variable is false.
---
 clang/lib/AST/ByteCode/Interp.cpp |  2 +-
 clang/test/AST/ByteCode/ms.cpp    | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 02beb38b7e2c65..4d3ee95df216c0 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -2998,7 +2998,7 @@ bool CheckPointerToIntegralCast(InterpState &S, CodePtr 
OpPC,
   S.CCEDiag(E, diag::note_constexpr_invalid_cast_ptrtoint)
       << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
       << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
-  if (Ptr.isBlockPointer() && !Ptr.isZero())
+  if ((Ptr.isBlockPointer() && !Ptr.isZero()) || Ptr.isOpaquePointer())
     S.CCEDiag(E, diag::note_constexpr_has_lvalue) << S.Current->getRange(OpPC);
   if (Ptr.isIntegralPointer())
     return true;
diff --git a/clang/test/AST/ByteCode/ms.cpp b/clang/test/AST/ByteCode/ms.cpp
index 35ffcbccae3b3a..b5c42e3ad78e2c 100644
--- a/clang/test/AST/ByteCode/ms.cpp
+++ b/clang/test/AST/ByteCode/ms.cpp
@@ -1,8 +1,5 @@
-// RUN: %clang_cc1 -verify=ref,both %s -fms-extensions -fcxx-exceptions
-// RUN: %clang_cc1 -verify=expected,both %s 
-fexperimental-new-constant-interpreter -fms-extensions -fcxx-exceptions
-
-// ref-no-diagnostics
-// expected-no-diagnostics
+// RUN: %clang_cc1 -verify=ref,both      %s                                    
     -fms-compatibility -fms-extensions -fcxx-exceptions
+// RUN: %clang_cc1 -verify=expected,both %s 
-fexperimental-new-constant-interpreter -fms-compatibility -fms-extensions 
-fcxx-exceptions
 
 /// Used to assert because the two parameters to _rotl do not have the same 
type.
 static_assert(_rotl(0x01, 5) == 32);
@@ -19,3 +16,12 @@ constexpr int noopIsActuallyNoop() {
     return a;
 }
 static_assert(noopIsActuallyNoop() == 0);
+
+
+auto foo() {
+  const __INTPTR_TYPE__ bar = (__INTPTR_TYPE__)&&label; // both-note {{via 
initialization of variable 'bar' here}}
+  return (void *)bar; // both-warning {{returning address of label, which is 
local}}
+label:
+} // both-warning {{C++23 extension}}
+
+

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

Reply via email to