generic.carbon 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: %F: %F.type = struct_value () [template]
  20. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  21. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  22. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  23. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  24. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  25. // CHECK:STDOUT: %.2: type = ptr_type %T [symbolic]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .Int = %import_ref
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/...
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = imports.%Core
  39. // CHECK:STDOUT: .F = %F.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @F() {
  46. // CHECK:STDOUT: !entry:
  47. // CHECK:STDOUT: %.loc12_18: Core.IntLiteral = int_value 32 [template = constants.%.1]
  48. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc12_18) [template = constants.%i32]
  49. // CHECK:STDOUT: %.loc12_21.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  50. // CHECK:STDOUT: %.loc12_21.2: type = converted %int.make_type_signed, %.loc12_21.1 [template = constants.%i32]
  51. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, %.loc12_21.2 [symbolic = constants.%T]
  52. // CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T [symbolic = constants.%T]
  53. // CHECK:STDOUT: %.loc13: type = ptr_type %T [symbolic = constants.%.2]
  54. // CHECK:STDOUT: %p.var: ref %.2 = var p
  55. // CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var
  56. // CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T [symbolic = constants.%T]
  57. // CHECK:STDOUT: %a.var: ref %T = var a
  58. // CHECK:STDOUT: %a: ref %T = bind_name a, %a.var
  59. // CHECK:STDOUT: %p.ref: ref %.2 = name_ref p, %p
  60. // CHECK:STDOUT: %.loc14_15: %.2 = bind_value %p.ref
  61. // CHECK:STDOUT: %.loc14_14.1: ref %T = deref %.loc14_15
  62. // CHECK:STDOUT: %.loc14_14.2: %T = bind_value %.loc14_14.1
  63. // CHECK:STDOUT: assign %a.var, %.loc14_14.2
  64. // CHECK:STDOUT: return
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: