https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/154788

Fixes #152920

>From 9dd7e0633c0b3486ac9a509d2dab5fe7b4896b98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com>
Date: Thu, 21 Aug 2025 18:09:01 +0200
Subject: [PATCH] [clang][bytecode] Implement Pointer::getType() for function
 pointers

Fixes #152920
---
 clang/lib/AST/ByteCode/Pointer.h      | 2 ++
 clang/test/AST/ByteCode/functions.cpp | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index f310c8a7b66be..0ce54ab0a17df 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -341,6 +341,8 @@ class Pointer {
   QualType getType() const {
     if (isTypeidPointer())
       return QualType(Typeid.TypeInfoType, 0);
+    if (isFunctionPointer())
+      return asFunctionPointer().getFunction()->getDecl()->getType();
 
     if (inPrimitiveArray() && Offset != asBlockPointer().Base) {
       // Unfortunately, complex and vector types are not array types in clang,
diff --git a/clang/test/AST/ByteCode/functions.cpp 
b/clang/test/AST/ByteCode/functions.cpp
index 4f090842510e0..01bf0a55bd19a 100644
--- a/clang/test/AST/ByteCode/functions.cpp
+++ b/clang/test/AST/ByteCode/functions.cpp
@@ -732,3 +732,8 @@ namespace LocalVarForParmVarDecl {
   }
   static_assert(foo(), "");
 }
+
+namespace PtrPtrCast {
+  void foo() { ; }
+  void bar(int *a) { a = (int *)(void *)(foo); }
+}

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to