mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 11:12:41 +00:00
This removes the builtin FunctionType, replacing it with a FunctionType instruction. The constant for a FunctionDecl is now a StructValue with type of FunctionType. Note this means a function declaration produces _both_ a type, and a value of the type. This has some consequences in terms of circularity, and makes the importing of function declarations a little more complex. It'll get particularly peculiar for imports because of the behavior of the reference, but that's a known issue due to other things such as `alias`. The impact will hopefully be contained to ResolvePrevInstForMerge (and ImportRefs). To note a small formatting change in diagnostics: ``` - // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable. + // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated F in Interface>` is not callable. - // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable. + // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated F in Interface>` is not callable. ``` --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
40 lines
2.1 KiB
Plaintext
40 lines
2.1 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
fn Run() -> i32 {
|
|
var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
|
|
var y: {.a: i32, .b: i32} = x;
|
|
return 0;
|
|
}
|
|
|
|
// CHECK:STDOUT: ; ModuleID = 'two_entries.carbon'
|
|
// CHECK:STDOUT: source_filename = "two_entries.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: @struct.2.loc8_47 = internal constant { i32, i32 } { i32 1, i32 2 }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define i32 @main() {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %x.var = alloca { i32, i32 }, align 8
|
|
// CHECK:STDOUT: %.loc8_46.2.a = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 0
|
|
// CHECK:STDOUT: %.loc8_46.4.b = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 1
|
|
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.2.loc8_47, i64 8, i1 false)
|
|
// CHECK:STDOUT: %y.var = alloca { i32, i32 }, align 8
|
|
// CHECK:STDOUT: %.loc9_31.1.a = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 0
|
|
// CHECK:STDOUT: %.loc9_31.2 = load i32, ptr %.loc9_31.1.a, align 4
|
|
// CHECK:STDOUT: %.loc9_31.3.a = getelementptr inbounds { i32, i32 }, ptr %y.var, i32 0, i32 0
|
|
// CHECK:STDOUT: store i32 %.loc9_31.2, ptr %.loc9_31.3.a, align 4
|
|
// CHECK:STDOUT: %.loc9_31.5.b = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 1
|
|
// CHECK:STDOUT: %.loc9_31.6 = load i32, ptr %.loc9_31.5.b, align 4
|
|
// CHECK:STDOUT: %.loc9_31.7.b = getelementptr inbounds { i32, i32 }, ptr %y.var, i32 0, i32 1
|
|
// CHECK:STDOUT: store i32 %.loc9_31.6, ptr %.loc9_31.7.b, align 4
|
|
// CHECK:STDOUT: ret i32 0
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
|
|
// CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
|