fail_bound_negative.carbon 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/fail_bound_negative.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_bound_negative.carbon
  10. fn Negate(n: i32) -> i32 = "int.snegate";
  11. // CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+3]]:14: error: array bound of -1 is negative [ArrayBoundNegative]
  12. // CHECK:STDERR: var a: [i32; Negate(1)];
  13. // CHECK:STDERR: ^~~~~~~~~
  14. var a: [i32; Negate(1)];
  15. // CHECK:STDOUT: --- fail_bound_negative.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  19. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  20. // CHECK:STDOUT: %Negate.type.1: type = fn_type @Negate.1 [template]
  21. // CHECK:STDOUT: %Negate: %Negate.type.1 = struct_value () [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: imports {
  25. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  26. // CHECK:STDOUT: .Int = %import_ref.1
  27. // CHECK:STDOUT: .ImplicitAs = %import_ref.5
  28. // CHECK:STDOUT: import Core//prelude
  29. // CHECK:STDOUT: import Core//prelude/...
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .Negate = %Negate.decl
  37. // CHECK:STDOUT: .a = %a
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %Negate.decl: %Negate.type.1 = fn_decl @Negate.1 [template = constants.%Negate] {
  41. // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
  42. // CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, runtime_param0
  43. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  44. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  45. // CHECK:STDOUT: } {
  46. // CHECK:STDOUT: %int_32.loc11_22: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  47. // CHECK:STDOUT: %i32.loc11_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  48. // CHECK:STDOUT: %n.param: %i32 = value_param runtime_param0
  49. // CHECK:STDOUT: %.loc11: type = splice_block %i32.loc11_14 [template = constants.%i32] {
  50. // CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  51. // CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
  54. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  55. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %a.var: ref <error> = var a
  58. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: fn @Negate.1(%n.param_patt: %i32) -> %i32 = "int.snegate";
  62. // CHECK:STDOUT: