fail_export_name_params.carbon 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/packages/fail_export_name_params.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/fail_export_name_params.carbon
  14. // --- a.carbon
  15. package Foo library "[[@TEST_NAME]]";
  16. class C1(T:! type);
  17. class C2(T:! type);
  18. // --- fail_b.carbon
  19. package Foo library "[[@TEST_NAME]]";
  20. import library "a";
  21. export C1;
  22. // CHECK:STDERR: fail_b.carbon:[[@LINE+4]]:10: error: `export` declaration cannot have parameters [UnexpectedDeclNameParams]
  23. // CHECK:STDERR: export C2(T:! type);
  24. // CHECK:STDERR: ^~~~~~~~~~
  25. // CHECK:STDERR:
  26. export C2(T:! type);
  27. // CHECK:STDOUT: --- a.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  31. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  32. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  33. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  34. // CHECK:STDOUT: %C1.type: type = generic_class_type @C1 [concrete]
  35. // CHECK:STDOUT: %C1.generic: %C1.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %C2.type: type = generic_class_type @C2 [concrete]
  37. // CHECK:STDOUT: %C2.generic: %C2.type = struct_value () [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  42. // CHECK:STDOUT: .C1 = %C1.decl
  43. // CHECK:STDOUT: .C2 = %C2.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %C1.decl: %C1.type = class_decl @C1 [concrete = constants.%C1.generic] {
  46. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  47. // CHECK:STDOUT: } {
  48. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  49. // CHECK:STDOUT: %T.loc4_10.2: type = symbolic_binding T, 0 [symbolic = %T.loc4_10.1 (constants.%T)]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %C2.decl: %C2.type = class_decl @C2 [concrete = constants.%C2.generic] {
  52. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  53. // CHECK:STDOUT: } {
  54. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  55. // CHECK:STDOUT: %T.loc5_10.2: type = symbolic_binding T, 0 [symbolic = %T.loc5_10.1 (constants.%T)]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: generic class @C1(%T.loc4_10.2: type) {
  60. // CHECK:STDOUT: %T.loc4_10.1: type = symbolic_binding T, 0 [symbolic = %T.loc4_10.1 (constants.%T)]
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class;
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: generic class @C2(%T.loc5_10.2: type) {
  66. // CHECK:STDOUT: %T.loc5_10.1: type = symbolic_binding T, 0 [symbolic = %T.loc5_10.1 (constants.%T)]
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: class;
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: specific @C1(constants.%T) {
  72. // CHECK:STDOUT: %T.loc4_10.1 => constants.%T
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: specific @C2(constants.%T) {
  76. // CHECK:STDOUT: %T.loc5_10.1 => constants.%T
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: --- fail_b.carbon
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: constants {
  82. // CHECK:STDOUT: %C1.type: type = generic_class_type @C1 [concrete]
  83. // CHECK:STDOUT: %C1.generic: %C1.type = struct_value () [concrete]
  84. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  85. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  86. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  87. // CHECK:STDOUT: %C2.type: type = generic_class_type @C2 [concrete]
  88. // CHECK:STDOUT: %C2.generic: %C2.type = struct_value () [concrete]
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: imports {
  92. // CHECK:STDOUT: %Foo.C1: %C1.type = import_ref Foo//a, C1, loaded [concrete = constants.%C1.generic]
  93. // CHECK:STDOUT: %Foo.C2: %C2.type = import_ref Foo//a, C2, loaded [concrete = constants.%C2.generic]
  94. // CHECK:STDOUT: %Foo.import_ref.b3bc94.1: type = import_ref Foo//a, loc4_10, loaded [symbolic = @C1.%T (constants.%T)]
  95. // CHECK:STDOUT: %Foo.import_ref.b3bc94.2: type = import_ref Foo//a, loc5_10, loaded [symbolic = @C2.%T (constants.%T)]
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: file {
  99. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  100. // CHECK:STDOUT: .C1 = %C1
  101. // CHECK:STDOUT: .C2 = %C2
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %default.import = import <none>
  104. // CHECK:STDOUT: %C1: %C1.type = export C1, imports.%Foo.C1 [concrete = constants.%C1.generic]
  105. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  106. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = constants.%T]
  107. // CHECK:STDOUT: %C2: %C2.type = export C2, imports.%Foo.C2 [concrete = constants.%C2.generic]
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: generic class @C1(imports.%Foo.import_ref.b3bc94.1: type) [from "a.carbon"] {
  111. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: class;
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: generic class @C2(imports.%Foo.import_ref.b3bc94.2: type) [from "a.carbon"] {
  117. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: class;
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: specific @C1(constants.%T) {
  123. // CHECK:STDOUT: %T => constants.%T
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: specific @C2(constants.%T) {
  127. // CHECK:STDOUT: %T => constants.%T
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: