mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 15:52:38 +00:00
`GlobalInit` block is now static block within a `SemIR` which will be used to emit initialization instructions for variables in the `Package` scope. inst_block_stack now has additional methods to handle `GlobalInit` block separately, this block can be popped without being finalized allowing to accumulate between all instances of variables. At the end of the `check` phase, if this block is not empty , the function `__global_init` will be added with this block being inserted into it. This block is pushed to `inst_block_scope` at the end `BindName`, allowing instruction to be emitted into it, then popped at the semicolon (VariableDecl). This significantly changes the `SemIR` output, that's why this commit updates a lot of the test cases.
30 lines
1.0 KiB
Plaintext
30 lines
1.0 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
|
|
|
|
var x: i32;
|
|
// CHECK:STDERR: fail_qualifier_unsupported.carbon:[[@LINE+3]]:14: ERROR: Type `i32` does not support qualified expressions.
|
|
// CHECK:STDERR: var y: i32 = x.b;
|
|
// CHECK:STDERR: ^~~
|
|
var y: i32 = x.b;
|
|
|
|
// CHECK:STDOUT: --- fail_qualifier_unsupported.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace {.x = %x, .y = %y} [template]
|
|
// CHECK:STDOUT: %x.var: ref i32 = var x
|
|
// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
|
|
// CHECK:STDOUT: %y.var: ref i32 = var y
|
|
// CHECK:STDOUT: %y: ref i32 = bind_name y, %y.var
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %x.ref: ref i32 = name_ref x, file.%x
|
|
// CHECK:STDOUT: assign file.%y.var, <error>
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|