|
|
@@ -3,6 +3,10 @@
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
//
|
|
|
// AUTOUPDATE
|
|
|
+// TIP: To test this file alone, run:
|
|
|
+// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/numeric_literals.carbon
|
|
|
+// TIP: To dump output, run:
|
|
|
+// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/numeric_literals.carbon
|
|
|
|
|
|
fn F() {
|
|
|
// 8 and 9 trigger special behavior in APInt when mishandling signed versus
|
|
|
@@ -76,76 +80,76 @@ fn F() {
|
|
|
// CHECK:STDOUT: fn @F() {
|
|
|
// CHECK:STDOUT: !entry:
|
|
|
// CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.2() [template = i32]
|
|
|
-// CHECK:STDOUT: %.loc10_19: i32 = int_literal 6 [template = constants.%.2]
|
|
|
-// CHECK:STDOUT: %.loc10_14.1: type = value_of_initializer %int.make_type_32 [template = i32]
|
|
|
-// CHECK:STDOUT: %.loc10_14.2: type = converted %int.make_type_32, %.loc10_14.1 [template = i32]
|
|
|
-// CHECK:STDOUT: %.loc10_20: type = array_type %.loc10_19, i32 [template = constants.%.3]
|
|
|
+// CHECK:STDOUT: %.loc14_19: i32 = int_literal 6 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %.loc14_14.1: type = value_of_initializer %int.make_type_32 [template = i32]
|
|
|
+// CHECK:STDOUT: %.loc14_14.2: type = converted %int.make_type_32, %.loc14_14.1 [template = i32]
|
|
|
+// CHECK:STDOUT: %.loc14_20: type = array_type %.loc14_19, i32 [template = constants.%.3]
|
|
|
// CHECK:STDOUT: %ints.var: ref [i32; 6] = var ints
|
|
|
// CHECK:STDOUT: %ints: ref [i32; 6] = bind_name ints, %ints.var
|
|
|
-// CHECK:STDOUT: %.loc11: i32 = int_literal 8 [template = constants.%.5]
|
|
|
-// CHECK:STDOUT: %.loc12: i32 = int_literal 9 [template = constants.%.6]
|
|
|
-// CHECK:STDOUT: %.loc13: i32 = int_literal 8 [template = constants.%.5]
|
|
|
-// CHECK:STDOUT: %.loc14: i32 = int_literal 8 [template = constants.%.5]
|
|
|
-// CHECK:STDOUT: %.loc15: i32 = int_literal 2147483647 [template = constants.%.7]
|
|
|
-// CHECK:STDOUT: %.loc16: i32 = int_literal 2147483647 [template = constants.%.7]
|
|
|
-// CHECK:STDOUT: %.loc17_3.1: (i32, i32, i32, i32, i32, i32) = tuple_literal (%.loc11, %.loc12, %.loc13, %.loc14, %.loc15, %.loc16)
|
|
|
-// CHECK:STDOUT: %.loc17_3.2: i32 = int_literal 0 [template = constants.%.9]
|
|
|
-// CHECK:STDOUT: %.loc17_3.3: ref i32 = array_index %ints.var, %.loc17_3.2
|
|
|
-// CHECK:STDOUT: %.loc17_3.4: init i32 = initialize_from %.loc11 to %.loc17_3.3 [template = constants.%.5]
|
|
|
-// CHECK:STDOUT: %.loc17_3.5: i32 = int_literal 1 [template = constants.%.10]
|
|
|
-// CHECK:STDOUT: %.loc17_3.6: ref i32 = array_index %ints.var, %.loc17_3.5
|
|
|
-// CHECK:STDOUT: %.loc17_3.7: init i32 = initialize_from %.loc12 to %.loc17_3.6 [template = constants.%.6]
|
|
|
-// CHECK:STDOUT: %.loc17_3.8: i32 = int_literal 2 [template = constants.%.11]
|
|
|
-// CHECK:STDOUT: %.loc17_3.9: ref i32 = array_index %ints.var, %.loc17_3.8
|
|
|
-// CHECK:STDOUT: %.loc17_3.10: init i32 = initialize_from %.loc13 to %.loc17_3.9 [template = constants.%.5]
|
|
|
-// CHECK:STDOUT: %.loc17_3.11: i32 = int_literal 3 [template = constants.%.12]
|
|
|
-// CHECK:STDOUT: %.loc17_3.12: ref i32 = array_index %ints.var, %.loc17_3.11
|
|
|
-// CHECK:STDOUT: %.loc17_3.13: init i32 = initialize_from %.loc14 to %.loc17_3.12 [template = constants.%.5]
|
|
|
-// CHECK:STDOUT: %.loc17_3.14: i32 = int_literal 4 [template = constants.%.13]
|
|
|
-// CHECK:STDOUT: %.loc17_3.15: ref i32 = array_index %ints.var, %.loc17_3.14
|
|
|
-// CHECK:STDOUT: %.loc17_3.16: init i32 = initialize_from %.loc15 to %.loc17_3.15 [template = constants.%.7]
|
|
|
-// CHECK:STDOUT: %.loc17_3.17: i32 = int_literal 5 [template = constants.%.14]
|
|
|
-// CHECK:STDOUT: %.loc17_3.18: ref i32 = array_index %ints.var, %.loc17_3.17
|
|
|
-// CHECK:STDOUT: %.loc17_3.19: init i32 = initialize_from %.loc16 to %.loc17_3.18 [template = constants.%.7]
|
|
|
-// CHECK:STDOUT: %.loc17_3.20: init [i32; 6] = array_init (%.loc17_3.4, %.loc17_3.7, %.loc17_3.10, %.loc17_3.13, %.loc17_3.16, %.loc17_3.19) to %ints.var [template = constants.%array.1]
|
|
|
-// CHECK:STDOUT: %.loc17_4: init [i32; 6] = converted %.loc17_3.1, %.loc17_3.20 [template = constants.%array.1]
|
|
|
-// CHECK:STDOUT: assign %ints.var, %.loc17_4
|
|
|
-// CHECK:STDOUT: %.loc18_16.1: i32 = int_literal 64 [template = constants.%.15]
|
|
|
-// CHECK:STDOUT: %float.make_type: init type = call constants.%struct.3(%.loc18_16.1) [template = f64]
|
|
|
-// CHECK:STDOUT: %.loc18_21: i32 = int_literal 6 [template = constants.%.2]
|
|
|
-// CHECK:STDOUT: %.loc18_16.2: type = value_of_initializer %float.make_type [template = f64]
|
|
|
-// CHECK:STDOUT: %.loc18_16.3: type = converted %float.make_type, %.loc18_16.2 [template = f64]
|
|
|
-// CHECK:STDOUT: %.loc18_22: type = array_type %.loc18_21, f64 [template = constants.%.16]
|
|
|
+// CHECK:STDOUT: %.loc15: i32 = int_literal 8 [template = constants.%.5]
|
|
|
+// CHECK:STDOUT: %.loc16: i32 = int_literal 9 [template = constants.%.6]
|
|
|
+// CHECK:STDOUT: %.loc17: i32 = int_literal 8 [template = constants.%.5]
|
|
|
+// CHECK:STDOUT: %.loc18: i32 = int_literal 8 [template = constants.%.5]
|
|
|
+// CHECK:STDOUT: %.loc19: i32 = int_literal 2147483647 [template = constants.%.7]
|
|
|
+// CHECK:STDOUT: %.loc20: i32 = int_literal 2147483647 [template = constants.%.7]
|
|
|
+// CHECK:STDOUT: %.loc21_3.1: (i32, i32, i32, i32, i32, i32) = tuple_literal (%.loc15, %.loc16, %.loc17, %.loc18, %.loc19, %.loc20)
|
|
|
+// CHECK:STDOUT: %.loc21_3.2: i32 = int_literal 0 [template = constants.%.9]
|
|
|
+// CHECK:STDOUT: %.loc21_3.3: ref i32 = array_index %ints.var, %.loc21_3.2
|
|
|
+// CHECK:STDOUT: %.loc21_3.4: init i32 = initialize_from %.loc15 to %.loc21_3.3 [template = constants.%.5]
|
|
|
+// CHECK:STDOUT: %.loc21_3.5: i32 = int_literal 1 [template = constants.%.10]
|
|
|
+// CHECK:STDOUT: %.loc21_3.6: ref i32 = array_index %ints.var, %.loc21_3.5
|
|
|
+// CHECK:STDOUT: %.loc21_3.7: init i32 = initialize_from %.loc16 to %.loc21_3.6 [template = constants.%.6]
|
|
|
+// CHECK:STDOUT: %.loc21_3.8: i32 = int_literal 2 [template = constants.%.11]
|
|
|
+// CHECK:STDOUT: %.loc21_3.9: ref i32 = array_index %ints.var, %.loc21_3.8
|
|
|
+// CHECK:STDOUT: %.loc21_3.10: init i32 = initialize_from %.loc17 to %.loc21_3.9 [template = constants.%.5]
|
|
|
+// CHECK:STDOUT: %.loc21_3.11: i32 = int_literal 3 [template = constants.%.12]
|
|
|
+// CHECK:STDOUT: %.loc21_3.12: ref i32 = array_index %ints.var, %.loc21_3.11
|
|
|
+// CHECK:STDOUT: %.loc21_3.13: init i32 = initialize_from %.loc18 to %.loc21_3.12 [template = constants.%.5]
|
|
|
+// CHECK:STDOUT: %.loc21_3.14: i32 = int_literal 4 [template = constants.%.13]
|
|
|
+// CHECK:STDOUT: %.loc21_3.15: ref i32 = array_index %ints.var, %.loc21_3.14
|
|
|
+// CHECK:STDOUT: %.loc21_3.16: init i32 = initialize_from %.loc19 to %.loc21_3.15 [template = constants.%.7]
|
|
|
+// CHECK:STDOUT: %.loc21_3.17: i32 = int_literal 5 [template = constants.%.14]
|
|
|
+// CHECK:STDOUT: %.loc21_3.18: ref i32 = array_index %ints.var, %.loc21_3.17
|
|
|
+// CHECK:STDOUT: %.loc21_3.19: init i32 = initialize_from %.loc20 to %.loc21_3.18 [template = constants.%.7]
|
|
|
+// CHECK:STDOUT: %.loc21_3.20: init [i32; 6] = array_init (%.loc21_3.4, %.loc21_3.7, %.loc21_3.10, %.loc21_3.13, %.loc21_3.16, %.loc21_3.19) to %ints.var [template = constants.%array.1]
|
|
|
+// CHECK:STDOUT: %.loc21_4: init [i32; 6] = converted %.loc21_3.1, %.loc21_3.20 [template = constants.%array.1]
|
|
|
+// CHECK:STDOUT: assign %ints.var, %.loc21_4
|
|
|
+// CHECK:STDOUT: %.loc22_16.1: i32 = int_literal 64 [template = constants.%.15]
|
|
|
+// CHECK:STDOUT: %float.make_type: init type = call constants.%struct.3(%.loc22_16.1) [template = f64]
|
|
|
+// CHECK:STDOUT: %.loc22_21: i32 = int_literal 6 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %.loc22_16.2: type = value_of_initializer %float.make_type [template = f64]
|
|
|
+// CHECK:STDOUT: %.loc22_16.3: type = converted %float.make_type, %.loc22_16.2 [template = f64]
|
|
|
+// CHECK:STDOUT: %.loc22_22: type = array_type %.loc22_21, f64 [template = constants.%.16]
|
|
|
// CHECK:STDOUT: %floats.var: ref [f64; 6] = var floats
|
|
|
// CHECK:STDOUT: %floats: ref [f64; 6] = bind_name floats, %floats.var
|
|
|
-// CHECK:STDOUT: %.loc19: f64 = float_literal 0.90000000000000002 [template = constants.%.18]
|
|
|
-// CHECK:STDOUT: %.loc20: f64 = float_literal 8 [template = constants.%.19]
|
|
|
-// CHECK:STDOUT: %.loc21: f64 = float_literal 80 [template = constants.%.20]
|
|
|
-// CHECK:STDOUT: %.loc22: f64 = float_literal 1.0E+7 [template = constants.%.21]
|
|
|
-// CHECK:STDOUT: %.loc23: f64 = float_literal 1.0E+8 [template = constants.%.22]
|
|
|
-// CHECK:STDOUT: %.loc24: f64 = float_literal 1.0E-8 [template = constants.%.23]
|
|
|
-// CHECK:STDOUT: %.loc25_3.1: (f64, f64, f64, f64, f64, f64) = tuple_literal (%.loc19, %.loc20, %.loc21, %.loc22, %.loc23, %.loc24)
|
|
|
-// CHECK:STDOUT: %.loc25_3.2: i32 = int_literal 0 [template = constants.%.9]
|
|
|
-// CHECK:STDOUT: %.loc25_3.3: ref f64 = array_index %floats.var, %.loc25_3.2
|
|
|
-// CHECK:STDOUT: %.loc25_3.4: init f64 = initialize_from %.loc19 to %.loc25_3.3 [template = constants.%.18]
|
|
|
-// CHECK:STDOUT: %.loc25_3.5: i32 = int_literal 1 [template = constants.%.10]
|
|
|
-// CHECK:STDOUT: %.loc25_3.6: ref f64 = array_index %floats.var, %.loc25_3.5
|
|
|
-// CHECK:STDOUT: %.loc25_3.7: init f64 = initialize_from %.loc20 to %.loc25_3.6 [template = constants.%.19]
|
|
|
-// CHECK:STDOUT: %.loc25_3.8: i32 = int_literal 2 [template = constants.%.11]
|
|
|
-// CHECK:STDOUT: %.loc25_3.9: ref f64 = array_index %floats.var, %.loc25_3.8
|
|
|
-// CHECK:STDOUT: %.loc25_3.10: init f64 = initialize_from %.loc21 to %.loc25_3.9 [template = constants.%.20]
|
|
|
-// CHECK:STDOUT: %.loc25_3.11: i32 = int_literal 3 [template = constants.%.12]
|
|
|
-// CHECK:STDOUT: %.loc25_3.12: ref f64 = array_index %floats.var, %.loc25_3.11
|
|
|
-// CHECK:STDOUT: %.loc25_3.13: init f64 = initialize_from %.loc22 to %.loc25_3.12 [template = constants.%.21]
|
|
|
-// CHECK:STDOUT: %.loc25_3.14: i32 = int_literal 4 [template = constants.%.13]
|
|
|
-// CHECK:STDOUT: %.loc25_3.15: ref f64 = array_index %floats.var, %.loc25_3.14
|
|
|
-// CHECK:STDOUT: %.loc25_3.16: init f64 = initialize_from %.loc23 to %.loc25_3.15 [template = constants.%.22]
|
|
|
-// CHECK:STDOUT: %.loc25_3.17: i32 = int_literal 5 [template = constants.%.14]
|
|
|
-// CHECK:STDOUT: %.loc25_3.18: ref f64 = array_index %floats.var, %.loc25_3.17
|
|
|
-// CHECK:STDOUT: %.loc25_3.19: init f64 = initialize_from %.loc24 to %.loc25_3.18 [template = constants.%.23]
|
|
|
-// CHECK:STDOUT: %.loc25_3.20: init [f64; 6] = array_init (%.loc25_3.4, %.loc25_3.7, %.loc25_3.10, %.loc25_3.13, %.loc25_3.16, %.loc25_3.19) to %floats.var [template = constants.%array.2]
|
|
|
-// CHECK:STDOUT: %.loc25_4: init [f64; 6] = converted %.loc25_3.1, %.loc25_3.20 [template = constants.%array.2]
|
|
|
-// CHECK:STDOUT: assign %floats.var, %.loc25_4
|
|
|
+// CHECK:STDOUT: %.loc23: f64 = float_literal 0.90000000000000002 [template = constants.%.18]
|
|
|
+// CHECK:STDOUT: %.loc24: f64 = float_literal 8 [template = constants.%.19]
|
|
|
+// CHECK:STDOUT: %.loc25: f64 = float_literal 80 [template = constants.%.20]
|
|
|
+// CHECK:STDOUT: %.loc26: f64 = float_literal 1.0E+7 [template = constants.%.21]
|
|
|
+// CHECK:STDOUT: %.loc27: f64 = float_literal 1.0E+8 [template = constants.%.22]
|
|
|
+// CHECK:STDOUT: %.loc28: f64 = float_literal 1.0E-8 [template = constants.%.23]
|
|
|
+// CHECK:STDOUT: %.loc29_3.1: (f64, f64, f64, f64, f64, f64) = tuple_literal (%.loc23, %.loc24, %.loc25, %.loc26, %.loc27, %.loc28)
|
|
|
+// CHECK:STDOUT: %.loc29_3.2: i32 = int_literal 0 [template = constants.%.9]
|
|
|
+// CHECK:STDOUT: %.loc29_3.3: ref f64 = array_index %floats.var, %.loc29_3.2
|
|
|
+// CHECK:STDOUT: %.loc29_3.4: init f64 = initialize_from %.loc23 to %.loc29_3.3 [template = constants.%.18]
|
|
|
+// CHECK:STDOUT: %.loc29_3.5: i32 = int_literal 1 [template = constants.%.10]
|
|
|
+// CHECK:STDOUT: %.loc29_3.6: ref f64 = array_index %floats.var, %.loc29_3.5
|
|
|
+// CHECK:STDOUT: %.loc29_3.7: init f64 = initialize_from %.loc24 to %.loc29_3.6 [template = constants.%.19]
|
|
|
+// CHECK:STDOUT: %.loc29_3.8: i32 = int_literal 2 [template = constants.%.11]
|
|
|
+// CHECK:STDOUT: %.loc29_3.9: ref f64 = array_index %floats.var, %.loc29_3.8
|
|
|
+// CHECK:STDOUT: %.loc29_3.10: init f64 = initialize_from %.loc25 to %.loc29_3.9 [template = constants.%.20]
|
|
|
+// CHECK:STDOUT: %.loc29_3.11: i32 = int_literal 3 [template = constants.%.12]
|
|
|
+// CHECK:STDOUT: %.loc29_3.12: ref f64 = array_index %floats.var, %.loc29_3.11
|
|
|
+// CHECK:STDOUT: %.loc29_3.13: init f64 = initialize_from %.loc26 to %.loc29_3.12 [template = constants.%.21]
|
|
|
+// CHECK:STDOUT: %.loc29_3.14: i32 = int_literal 4 [template = constants.%.13]
|
|
|
+// CHECK:STDOUT: %.loc29_3.15: ref f64 = array_index %floats.var, %.loc29_3.14
|
|
|
+// CHECK:STDOUT: %.loc29_3.16: init f64 = initialize_from %.loc27 to %.loc29_3.15 [template = constants.%.22]
|
|
|
+// CHECK:STDOUT: %.loc29_3.17: i32 = int_literal 5 [template = constants.%.14]
|
|
|
+// CHECK:STDOUT: %.loc29_3.18: ref f64 = array_index %floats.var, %.loc29_3.17
|
|
|
+// CHECK:STDOUT: %.loc29_3.19: init f64 = initialize_from %.loc28 to %.loc29_3.18 [template = constants.%.23]
|
|
|
+// CHECK:STDOUT: %.loc29_3.20: init [f64; 6] = array_init (%.loc29_3.4, %.loc29_3.7, %.loc29_3.10, %.loc29_3.13, %.loc29_3.16, %.loc29_3.19) to %floats.var [template = constants.%array.2]
|
|
|
+// CHECK:STDOUT: %.loc29_4: init [f64; 6] = converted %.loc29_3.1, %.loc29_3.20 [template = constants.%array.2]
|
|
|
+// CHECK:STDOUT: assign %floats.var, %.loc29_4
|
|
|
// CHECK:STDOUT: return
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|