generic.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/let/generic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/generic.carbon
  10. fn F() {
  11. let T:! type = i32;
  12. var p: T*;
  13. var a: T = *p;
  14. }
  15. // CHECK:STDOUT: --- generic.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  19. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  20. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  21. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  22. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  23. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  24. // CHECK:STDOUT: %.2: type = ptr_type %T [symbolic]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Core = %Core
  30. // CHECK:STDOUT: .F = %F.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  33. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  34. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: fn @F() {
  38. // CHECK:STDOUT: !entry:
  39. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  40. // CHECK:STDOUT: %.loc12_21.1: type = value_of_initializer %int.make_type_32 [template = i32]
  41. // CHECK:STDOUT: %.loc12_21.2: type = converted %int.make_type_32, %.loc12_21.1 [template = i32]
  42. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, %.loc12_21.2 [symbolic = constants.%T]
  43. // CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T [symbolic = constants.%T]
  44. // CHECK:STDOUT: %.loc13: type = ptr_type %T [symbolic = constants.%.2]
  45. // CHECK:STDOUT: %p.var: ref %.2 = var p
  46. // CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var
  47. // CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T [symbolic = constants.%T]
  48. // CHECK:STDOUT: %a.var: ref %T = var a
  49. // CHECK:STDOUT: %a: ref %T = bind_name a, %a.var
  50. // CHECK:STDOUT: %p.ref: ref %.2 = name_ref p, %p
  51. // CHECK:STDOUT: %.loc14_15: %.2 = bind_value %p.ref
  52. // CHECK:STDOUT: %.loc14_14.1: ref %T = deref %.loc14_15
  53. // CHECK:STDOUT: %.loc14_14.2: %T = bind_value %.loc14_14.1
  54. // CHECK:STDOUT: assign %a.var, %.loc14_14.2
  55. // CHECK:STDOUT: return
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  59. // CHECK:STDOUT: