mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 22:02:41 +01:00
Adds `BindAlias` with a hybrid of `BindName` and `NameRef` semantics. I think it's slightly closer to `BindName` because it introduces a name, so I'm going more in that direction. This also matches the need for `bind_name_id` with imports on enclosing scopes. Note, only things that look like a name reference are being allowed on the RHS of `alias`. This includes builtins that look like name references, such as `bool`, but not ones that turn into values underneath, such as `false`.
22 lines
612 B
Plaintext
22 lines
612 B
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 F() -> i32 {
|
|
var a: i32 = 0;
|
|
alias b = a;
|
|
return b;
|
|
}
|
|
|
|
// CHECK:STDOUT: ; ModuleID = 'local.carbon'
|
|
// CHECK:STDOUT: source_filename = "local.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define i32 @F() {
|
|
// CHECK:STDOUT: %a = alloca i32, align 4
|
|
// CHECK:STDOUT: store i32 0, ptr %a, align 4
|
|
// CHECK:STDOUT: %1 = load i32, ptr %a, align 4
|
|
// CHECK:STDOUT: ret i32 %1
|
|
// CHECK:STDOUT: }
|