Files
carbon-lang/toolchain/check/testdata/index/array_element_access.carbon
T
Richard Smith 71e9fb7511 Disable raw IR printing in tests by default. (#3204)
Add a couple more tests to check/testdata/basic/ to explicitly test the
raw dump.
2023-09-07 21:11:44 +00:00

37 lines
1.5 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 a: [i32; 2] = (12, 24);
var b: i32 = 1;
var c: i32 = a[0];
var d: i32 = a[b];
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc7_14: i32 = int_literal 2
// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32
// CHECK:STDOUT: %a: ref [i32; 2] = var "a"
// CHECK:STDOUT: %.loc7_20.1: i32 = int_literal 12
// CHECK:STDOUT: %.loc7_20.2: i32 = stub_reference %.loc7_20.1
// CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 24
// CHECK:STDOUT: %.loc7_24.2: i32 = stub_reference %.loc7_24.1
// CHECK:STDOUT: %.loc7_26.1: type = tuple_type (i32, i32)
// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = tuple_value (%.loc7_20.2, %.loc7_24.2)
// CHECK:STDOUT: %.loc7_26.3: [i32; 2] = array_value %.loc7_26.2
// CHECK:STDOUT: assign %a, %.loc7_26.3
// CHECK:STDOUT: %b: ref i32 = var "b"
// CHECK:STDOUT: %.loc8: i32 = int_literal 1
// CHECK:STDOUT: assign %b, %.loc8
// CHECK:STDOUT: %c: ref i32 = var "c"
// CHECK:STDOUT: %.loc9_16: i32 = int_literal 0
// CHECK:STDOUT: %.loc9_17.1: ref i32 = array_index %a, %.loc9_16
// CHECK:STDOUT: %.loc9_17.2: i32 = bind_value %.loc9_17.1
// CHECK:STDOUT: assign %c, %.loc9_17.2
// CHECK:STDOUT: %d: ref i32 = var "d"
// CHECK:STDOUT: %.loc10_17.1: ref i32 = array_index %a, %b
// CHECK:STDOUT: %.loc10_17.2: i32 = bind_value %.loc10_17.1
// CHECK:STDOUT: assign %d, %.loc10_17.2
// CHECK:STDOUT: }