[PATCH] D141472: [clang][Interp] Add function pointers
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 23 23:01:08 PDT 2023
tbaeder added a comment.
In D141472#4217479 <https://reviews.llvm.org/D141472#4217479>, @aaron.ballman wrote:
> In D141472#4112790 <https://reviews.llvm.org/D141472#4112790>, @tbaeder wrote:
>
>> I'm not sure what to do about this right now. I was wondering about restructuring pointers so all the metadata is before all the actual data, but that would be a large refactoring.
>
> For right now, we can move forward with basic function pointer support and we can revisit this when you get around to doing member function pointers.
FWIW, I did that refactoring locally but it didn't really turn out to work like that. This example works now and there should be a test for it AFAIK.
================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:970
return this->emitNullPtr(E);
+ case PT_FnPtr:
case PT_Float:
----------------
aaron.ballman wrote:
> Shouldn't this call `emitNullPtr()` in this case? e.g.,
> ```
> struct S {
> int i;
> void (*fp)();
> };
>
> constexpr S s{ 12 };
> static_assert(s.fp == nullptr);
> ```
Heh, that function is dead code right now, I keep it around because I think I might need it later. But your reproducer is broken anyway, I'll fix it, thanks.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141472/new/
https://reviews.llvm.org/D141472
More information about the cfe-commits
mailing list