alias_of_alias.carbon 2.6 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/alias_of_alias.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/alias_of_alias.carbon
  10. class C {}
  11. alias a = C;
  12. alias b = a;
  13. alias c = b;
  14. let d: c = {};
  15. // CHECK:STDOUT: --- alias_of_alias.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %C: type = class_type @C [template]
  19. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  20. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  21. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  22. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .C = %C.decl
  28. // CHECK:STDOUT: .a = %a
  29. // CHECK:STDOUT: .b = %b
  30. // CHECK:STDOUT: .c = %c
  31. // CHECK:STDOUT: .d = @__global_init.%d
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  34. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  35. // CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C]
  36. // CHECK:STDOUT: %a.ref: type = name_ref a, %a [template = constants.%C]
  37. // CHECK:STDOUT: %b: type = bind_alias b, %a [template = constants.%C]
  38. // CHECK:STDOUT: %b.ref: type = name_ref b, %b [template = constants.%C]
  39. // CHECK:STDOUT: %c: type = bind_alias c, %b [template = constants.%C]
  40. // CHECK:STDOUT: %c.ref: type = name_ref c, %c [template = constants.%C]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: class @C {
  44. // CHECK:STDOUT: !members:
  45. // CHECK:STDOUT: .Self = constants.%C
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @__global_init() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %.loc15_13.1: %.1 = struct_literal ()
  51. // CHECK:STDOUT: %.loc15_13.2: ref %C = temporary_storage
  52. // CHECK:STDOUT: %.loc15_13.3: init %C = class_init (), %.loc15_13.2 [template = constants.%struct]
  53. // CHECK:STDOUT: %.loc15_13.4: ref %C = temporary %.loc15_13.2, %.loc15_13.3
  54. // CHECK:STDOUT: %.loc15_14.1: ref %C = converted %.loc15_13.1, %.loc15_13.4
  55. // CHECK:STDOUT: %.loc15_14.2: %C = bind_value %.loc15_14.1
  56. // CHECK:STDOUT: %d: %C = bind_name d, %.loc15_14.2
  57. // CHECK:STDOUT: return
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: