Support for converting a function to a C++ function pointer (#7789)

This commit is contained in:
Geoff Romer
2026-09-30 21:13:36 +00:00
committed by GitHub
parent cbdd6cee65
commit c0bd9606de
26 changed files with 1030 additions and 446 deletions
@@ -13,14 +13,14 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_function.carbon
fn A() {
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:4: error: expression cannot be used as a value [UseOfNonExprAsValue]
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:3: error: cannot dereference operand of non-pointer type `<type of A>` [DerefOfNonPointer]
// CHECK:STDERR: *A;
// CHECK:STDERR: ^
// CHECK:STDERR: ^
// CHECK:STDERR:
*A;
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:4: error: cannot apply `->` operator to non-pointer type `<type of A>` [ArrowOperatorOfNonPointer]
// CHECK:STDERR: A->foo;
// CHECK:STDERR: ^
// CHECK:STDERR: ^~
// CHECK:STDERR:
A->foo;
}
@@ -52,9 +52,9 @@ fn A() {
// CHECK:STDOUT: fn @A() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %A.ref.loc20: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %.loc20: ref <error> = deref <error> [concrete = <error>]
// CHECK:STDOUT: %.loc20: ref <error> = deref %A.ref.loc20 [concrete = <error>]
// CHECK:STDOUT: %A.ref.loc25: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %.loc25: ref <error> = deref <error> [concrete = <error>]
// CHECK:STDOUT: %.loc25: ref <error> = deref %A.ref.loc25 [concrete = <error>]
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }