fail_not_constant.carbon 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/alias/no_prelude/fail_not_constant.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon
  10. fn F() {
  11. var a: () = ();
  12. var b: ()* = &a;
  13. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:13: ERROR: Alias initializer must be a name reference.
  14. // CHECK:STDERR: alias c = *b;
  15. // CHECK:STDERR: ^~
  16. alias c = *b;
  17. }
  18. // CHECK:STDOUT: --- fail_not_constant.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  24. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  25. // CHECK:STDOUT: %.2: type = ptr_type %.1 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .F = %F.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @F() {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: %.loc12_11.1: %.1 = tuple_literal ()
  38. // CHECK:STDOUT: %.loc12_11.2: type = converted %.loc12_11.1, constants.%.1 [template = constants.%.1]
  39. // CHECK:STDOUT: %a.var: ref %.1 = var a
  40. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  41. // CHECK:STDOUT: %.loc12_16.1: %.1 = tuple_literal ()
  42. // CHECK:STDOUT: %.loc12_16.2: init %.1 = tuple_init () to %a.var [template = constants.%tuple]
  43. // CHECK:STDOUT: %.loc12_17: init %.1 = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%tuple]
  44. // CHECK:STDOUT: assign %a.var, %.loc12_17
  45. // CHECK:STDOUT: %.loc13_11: %.1 = tuple_literal ()
  46. // CHECK:STDOUT: %.loc13_12.1: type = converted %.loc13_11, constants.%.1 [template = constants.%.1]
  47. // CHECK:STDOUT: %.loc13_12.2: type = ptr_type %.1 [template = constants.%.2]
  48. // CHECK:STDOUT: %b.var: ref %.2 = var b
  49. // CHECK:STDOUT: %b: ref %.2 = bind_name b, %b.var
  50. // CHECK:STDOUT: %a.ref: ref %.1 = name_ref a, %a
  51. // CHECK:STDOUT: %.loc13_16: %.2 = addr_of %a.ref
  52. // CHECK:STDOUT: assign %b.var, %.loc13_16
  53. // CHECK:STDOUT: %b.ref: ref %.2 = name_ref b, %b
  54. // CHECK:STDOUT: %.loc17_14: %.2 = bind_value %b.ref
  55. // CHECK:STDOUT: %.loc17_13: ref %.1 = deref %.loc17_14
  56. // CHECK:STDOUT: %c: <error> = bind_alias c, <error> [template = <error>]
  57. // CHECK:STDOUT: return
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: