raw_identifier.carbon 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/basics/no_prelude/raw_identifier.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/no_prelude/raw_identifier.carbon
  10. fn A(n: ()) -> () {
  11. return r#n;
  12. }
  13. fn B(r#n: ()) -> () {
  14. return n;
  15. }
  16. fn C(r#if: ()) -> () {
  17. return r#if;
  18. }
  19. // CHECK:STDOUT: --- raw_identifier.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  23. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  24. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  25. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  26. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  27. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  28. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  33. // CHECK:STDOUT: .A = %A.decl
  34. // CHECK:STDOUT: .B = %B.decl
  35. // CHECK:STDOUT: .C = %C.decl
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {
  38. // CHECK:STDOUT: %n.patt: %empty_tuple.type = binding_pattern n
  39. // CHECK:STDOUT: %n.param_patt: %empty_tuple.type = value_param_pattern %n.patt, runtime_param0
  40. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  41. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param1
  42. // CHECK:STDOUT: } {
  43. // CHECK:STDOUT: %.loc11_17.1: %empty_tuple.type = tuple_literal ()
  44. // CHECK:STDOUT: %.loc11_17.2: type = converted %.loc11_17.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  45. // CHECK:STDOUT: %n.param: %empty_tuple.type = value_param runtime_param0
  46. // CHECK:STDOUT: %.loc11_10.1: type = splice_block %.loc11_10.3 [template = constants.%empty_tuple.type] {
  47. // CHECK:STDOUT: %.loc11_10.2: %empty_tuple.type = tuple_literal ()
  48. // CHECK:STDOUT: %.loc11_10.3: type = converted %.loc11_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %n: %empty_tuple.type = bind_name n, %n.param
  51. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param1
  52. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  55. // CHECK:STDOUT: %n.patt: %empty_tuple.type = binding_pattern n
  56. // CHECK:STDOUT: %n.param_patt: %empty_tuple.type = value_param_pattern %n.patt, runtime_param0
  57. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  58. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param1
  59. // CHECK:STDOUT: } {
  60. // CHECK:STDOUT: %.loc15_19.1: %empty_tuple.type = tuple_literal ()
  61. // CHECK:STDOUT: %.loc15_19.2: type = converted %.loc15_19.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  62. // CHECK:STDOUT: %n.param: %empty_tuple.type = value_param runtime_param0
  63. // CHECK:STDOUT: %.loc15_12.1: type = splice_block %.loc15_12.3 [template = constants.%empty_tuple.type] {
  64. // CHECK:STDOUT: %.loc15_12.2: %empty_tuple.type = tuple_literal ()
  65. // CHECK:STDOUT: %.loc15_12.3: type = converted %.loc15_12.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %n: %empty_tuple.type = bind_name n, %n.param
  68. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param1
  69. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  72. // CHECK:STDOUT: %if.patt: %empty_tuple.type = binding_pattern r#if
  73. // CHECK:STDOUT: %if.param_patt: %empty_tuple.type = value_param_pattern %if.patt, runtime_param0
  74. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  75. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param1
  76. // CHECK:STDOUT: } {
  77. // CHECK:STDOUT: %.loc19_20.1: %empty_tuple.type = tuple_literal ()
  78. // CHECK:STDOUT: %.loc19_20.2: type = converted %.loc19_20.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  79. // CHECK:STDOUT: %if.param: %empty_tuple.type = value_param runtime_param0
  80. // CHECK:STDOUT: %.loc19_13.1: type = splice_block %.loc19_13.3 [template = constants.%empty_tuple.type] {
  81. // CHECK:STDOUT: %.loc19_13.2: %empty_tuple.type = tuple_literal ()
  82. // CHECK:STDOUT: %.loc19_13.3: type = converted %.loc19_13.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %if: %empty_tuple.type = bind_name r#if, %if.param
  85. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param1
  86. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @A(%n.param_patt: %empty_tuple.type) -> %empty_tuple.type {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: %n.ref: %empty_tuple.type = name_ref n, %n
  93. // CHECK:STDOUT: return %n.ref
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: fn @B(%n.param_patt: %empty_tuple.type) -> %empty_tuple.type {
  97. // CHECK:STDOUT: !entry:
  98. // CHECK:STDOUT: %n.ref: %empty_tuple.type = name_ref n, %n
  99. // CHECK:STDOUT: return %n.ref
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: fn @C(%if.param_patt: %empty_tuple.type) -> %empty_tuple.type {
  103. // CHECK:STDOUT: !entry:
  104. // CHECK:STDOUT: %if.ref: %empty_tuple.type = name_ref r#if, %if
  105. // CHECK:STDOUT: return %if.ref
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: