fail_bound_negative.carbon 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. fn Negate(n: i32) -> i32 = "int.negate";
  7. // CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+3]]:14: ERROR: Array bound of -1 is negative.
  8. // CHECK:STDERR: var a: [i32; Negate(1)];
  9. // CHECK:STDERR: ^~~~~~~
  10. var a: [i32; Negate(1)];
  11. // CHECK:STDOUT: --- fail_bound_negative.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  15. // CHECK:STDOUT: %.2: i32 = int_literal -1 [template]
  16. // CHECK:STDOUT: }
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: file {
  19. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  20. // CHECK:STDOUT: .Negate = %Negate
  21. // CHECK:STDOUT: .a = %a
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT: %Negate: <function> = fn_decl @Negate [template] {
  24. // CHECK:STDOUT: %n.loc7_11.1: i32 = param n
  25. // CHECK:STDOUT: @Negate.%n: i32 = bind_name n, %n.loc7_11.1
  26. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT: %Negate.ref: <function> = name_ref Negate, %Negate [template = %Negate]
  29. // CHECK:STDOUT: %.loc12_21: i32 = int_literal 1 [template = constants.%.1]
  30. // CHECK:STDOUT: %.loc12_20: init i32 = call %Negate.ref(%.loc12_21) [template = constants.%.2]
  31. // CHECK:STDOUT: %.loc12_23: type = array_type %.loc12_20, i32 [template = <error>]
  32. // CHECK:STDOUT: %a.var: ref <error> = var a
  33. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: fn @Negate(%n: i32) -> i32 = "int.negate";
  37. // CHECK:STDOUT: