Skip to content

Conversation

@tbaederr
Copy link
Contributor

Fixes #152920

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Aug 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

Fixes #152920


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

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Pointer.h (+2)
  • (modified) clang/test/AST/ByteCode/functions.cpp (+5)
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); }
+}

@tbaederr tbaederr merged commit 8b09196 into llvm:main Aug 21, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[clang][bytecode] crash when passing function name to __builtin_assume_aligned

2 participants