Files
carbon-lang/toolchain/lowering/testdata/struct/empty.carbon
T
Jon Ross-Perkins 76151d1fff Stop special-casing empty structs. (#2849)
This removes special-casing of empty structs, handling them as just a regular value instead of a builtin. Note the `{} as Type` is still special-cased.

In lowering, removes the test of calling a function using `{}` because it's missing the proper load/store. This setup notices that error whereas the prior worked due to said special-casing. Fixing this will need to be done as part of generally adding loads for variable uses.
2023-05-26 10:33:17 -07:00

30 lines
1.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
// CHECK:STDOUT: ; ModuleID = 'empty.carbon'
// CHECK:STDOUT: source_filename = "empty.carbon"
// CHECK:STDOUT:
// CHECK:STDOUT: %StructLiteralType = type {}
// CHECK:STDOUT: %StructLiteralType.0 = type {}
// CHECK:STDOUT: %StructLiteralType.1 = type {}
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @Run() {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %StructLiteralValue = alloca %StructLiteralType, align 8
// CHECK:STDOUT: %var = alloca %StructLiteralType, align 8
// CHECK:STDOUT: %StructLiteralValue1 = alloca %StructLiteralType.0, align 8
// CHECK:STDOUT: store ptr %StructLiteralValue1, ptr %var, align 8
// CHECK:STDOUT: %StructLiteralValue2 = alloca %StructLiteralType.1, align 8
// CHECK:STDOUT: %var3 = alloca %StructLiteralType.1, align 8
// CHECK:STDOUT: store ptr %var, ptr %var3, align 8
// CHECK:STDOUT: ret i32 0
// CHECK:STDOUT: }
fn Run() -> i32 {
var x: {} = {};
var y: {} = x;
return 0;
}