fail_aggregate.carbon 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // TODO: This creates an array temporary, which we don't yet support evaluating.
  7. // CHECK:STDERR: fail_aggregate.carbon:[[@LINE+3]]:43: ERROR: Array bound is not a constant.
  8. // CHECK:STDERR: var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]];
  9. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]];
  11. // CHECK:STDOUT: --- fail_aggregate.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  15. // CHECK:STDOUT: %.2: type = array_type %.1, i32 [template]
  16. // CHECK:STDOUT: %.3: type = ptr_type [i32; 1] [template]
  17. // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
  18. // CHECK:STDOUT: %.5: type = tuple_type (i32) [template]
  19. // CHECK:STDOUT: %.6: i32 = int_literal 5 [template]
  20. // CHECK:STDOUT: %.7: i32 = int_literal 7 [template]
  21. // CHECK:STDOUT: %.8: i32 = int_literal 9 [template]
  22. // CHECK:STDOUT: %.9: type = tuple_type (i32, i32, i32, i32) [template]
  23. // CHECK:STDOUT: %.10: i32 = int_literal 4 [template]
  24. // CHECK:STDOUT: %.11: type = array_type %.10, i32 [template]
  25. // CHECK:STDOUT: %.12: type = ptr_type [i32; 4] [template]
  26. // CHECK:STDOUT: %.13: i32 = int_literal 2 [template]
  27. // CHECK:STDOUT: %.14: i32 = int_literal 3 [template]
  28. // CHECK:STDOUT: %.15: [i32; 4] = tuple_value (%.6, %.7, %.1, %.8) [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  33. // CHECK:STDOUT: .array_index = %array_index
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %.loc12_24: i32 = int_literal 1 [template = constants.%.1]
  36. // CHECK:STDOUT: %.loc12_25: type = array_type %.loc12_24, i32 [template = constants.%.2]
  37. // CHECK:STDOUT: %array_index.var: ref [i32; 1] = var array_index
  38. // CHECK:STDOUT: %array_index: ref [i32; 1] = bind_name array_index, %array_index.var
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: fn @__global_init() {
  42. // CHECK:STDOUT: !entry:
  43. // CHECK:STDOUT: %.loc12_30: i32 = int_literal 0 [template = constants.%.4]
  44. // CHECK:STDOUT: %.loc12_32: (i32,) = tuple_literal (%.loc12_30)
  45. // CHECK:STDOUT: %.loc12_45: i32 = int_literal 5 [template = constants.%.6]
  46. // CHECK:STDOUT: %.loc12_48: i32 = int_literal 7 [template = constants.%.7]
  47. // CHECK:STDOUT: %.loc12_51: i32 = int_literal 1 [template = constants.%.1]
  48. // CHECK:STDOUT: %.loc12_54: i32 = int_literal 9 [template = constants.%.8]
  49. // CHECK:STDOUT: %.loc12_55.1: (i32, i32, i32, i32) = tuple_literal (%.loc12_45, %.loc12_48, %.loc12_51, %.loc12_54)
  50. // CHECK:STDOUT: %.loc12_66: i32 = int_literal 4 [template = constants.%.10]
  51. // CHECK:STDOUT: %.loc12_67: type = array_type %.loc12_66, i32 [template = constants.%.11]
  52. // CHECK:STDOUT: %.loc12_55.2: ref [i32; 4] = temporary_storage
  53. // CHECK:STDOUT: %.loc12_55.3: i32 = int_literal 0 [template = constants.%.4]
  54. // CHECK:STDOUT: %.loc12_55.4: ref i32 = array_index %.loc12_55.2, %.loc12_55.3
  55. // CHECK:STDOUT: %.loc12_55.5: init i32 = initialize_from %.loc12_45 to %.loc12_55.4 [template = constants.%.6]
  56. // CHECK:STDOUT: %.loc12_55.6: i32 = int_literal 1 [template = constants.%.1]
  57. // CHECK:STDOUT: %.loc12_55.7: ref i32 = array_index %.loc12_55.2, %.loc12_55.6
  58. // CHECK:STDOUT: %.loc12_55.8: init i32 = initialize_from %.loc12_48 to %.loc12_55.7 [template = constants.%.7]
  59. // CHECK:STDOUT: %.loc12_55.9: i32 = int_literal 2 [template = constants.%.13]
  60. // CHECK:STDOUT: %.loc12_55.10: ref i32 = array_index %.loc12_55.2, %.loc12_55.9
  61. // CHECK:STDOUT: %.loc12_55.11: init i32 = initialize_from %.loc12_51 to %.loc12_55.10 [template = constants.%.1]
  62. // CHECK:STDOUT: %.loc12_55.12: i32 = int_literal 3 [template = constants.%.14]
  63. // CHECK:STDOUT: %.loc12_55.13: ref i32 = array_index %.loc12_55.2, %.loc12_55.12
  64. // CHECK:STDOUT: %.loc12_55.14: init i32 = initialize_from %.loc12_54 to %.loc12_55.13 [template = constants.%.8]
  65. // CHECK:STDOUT: %.loc12_55.15: init [i32; 4] = array_init (%.loc12_55.5, %.loc12_55.8, %.loc12_55.11, %.loc12_55.14) to %.loc12_55.2 [template = constants.%.15]
  66. // CHECK:STDOUT: %.loc12_55.16: init [i32; 4] = converted %.loc12_55.1, %.loc12_55.15 [template = constants.%.15]
  67. // CHECK:STDOUT: %.loc12_70: i32 = int_literal 2 [template = constants.%.13]
  68. // CHECK:STDOUT: %.loc12_55.17: ref [i32; 4] = temporary %.loc12_55.2, %.loc12_55.16
  69. // CHECK:STDOUT: %.loc12_71.1: ref i32 = array_index %.loc12_55.17, %.loc12_70
  70. // CHECK:STDOUT: %.loc12_71.2: i32 = bind_value %.loc12_71.1
  71. // CHECK:STDOUT: assign file.%array_index.var, <error>
  72. // CHECK:STDOUT: return
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: