generic_empty.carbon 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/array/generic_empty.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/generic_empty.carbon
  10. fn G(T:! type) {
  11. // We can initialize this without knowing T.
  12. var arr: [T; 0] = ();
  13. }
  14. // CHECK:STDOUT: --- generic_empty.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  18. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  19. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  20. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  21. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  22. // CHECK:STDOUT: %.3: type = array_type %.2, %T [symbolic]
  23. // CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic]
  24. // CHECK:STDOUT: %array: %.3 = tuple_value () [symbolic]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Core = %Core
  30. // CHECK:STDOUT: .G = %G.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %Core.import = import Core
  33. // CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
  34. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  35. // CHECK:STDOUT: %T.loc11_6.1: type = param T
  36. // CHECK:STDOUT: @G.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = constants.%T]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: fn @G(%T: type)
  41. // CHECK:STDOUT: generic [%T: type] {
  42. // CHECK:STDOUT: !entry:
  43. // CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T]
  44. // CHECK:STDOUT: %.loc13_16: i32 = int_literal 0 [template = constants.%.2]
  45. // CHECK:STDOUT: %.loc13_17: type = array_type %.loc13_16, %T [symbolic = constants.%.3]
  46. // CHECK:STDOUT: %arr.var: ref %.3 = var arr
  47. // CHECK:STDOUT: %arr: ref %.3 = bind_name arr, %arr.var
  48. // CHECK:STDOUT: %.loc13_22.1: %.1 = tuple_literal ()
  49. // CHECK:STDOUT: %.loc13_22.2: init %.3 = array_init () to %arr.var [symbolic = constants.%array]
  50. // CHECK:STDOUT: %.loc13_23: init %.3 = converted %.loc13_22.1, %.loc13_22.2 [symbolic = constants.%array]
  51. // CHECK:STDOUT: assign %arr.var, %.loc13_23
  52. // CHECK:STDOUT: return
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: