Skip to content

Commit 8b09196

Browse files
authored
[clang][bytecode] Implement Pointer::getType() for function pointers (#154788)
Fixes #152920
1 parent e41aaf5 commit 8b09196

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ class Pointer {
341341
QualType getType() const {
342342
if (isTypeidPointer())
343343
return QualType(Typeid.TypeInfoType, 0);
344+
if (isFunctionPointer())
345+
return asFunctionPointer().getFunction()->getDecl()->getType();
344346

345347
if (inPrimitiveArray() && Offset != asBlockPointer().Base) {
346348
// Unfortunately, complex and vector types are not array types in clang,

clang/test/AST/ByteCode/functions.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,3 +732,8 @@ namespace LocalVarForParmVarDecl {
732732
}
733733
static_assert(foo(), "");
734734
}
735+
736+
namespace PtrPtrCast {
737+
void foo() { ; }
738+
void bar(int *a) { a = (int *)(void *)(foo); }
739+
}

0 commit comments

Comments
 (0)