basics.carbon 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/function/definition/basics.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/basics.carbon
  14. // --- fail_incomplete_type.carbon
  15. class C;
  16. // CHECK:STDERR: fail_incomplete_type.carbon:[[@LINE+7]]:6: error: parameter has incomplete type `C` in function definition [IncompleteTypeInFunctionParam]
  17. // CHECK:STDERR: fn F(n: C) {}
  18. // CHECK:STDERR: ^~~~
  19. // CHECK:STDERR: fail_incomplete_type.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
  20. // CHECK:STDERR: class C;
  21. // CHECK:STDERR: ^~~~~~~~
  22. // CHECK:STDERR:
  23. fn F(n: C) {}
  24. // CHECK:STDOUT: --- fail_incomplete_type.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  28. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  29. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  30. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  35. // CHECK:STDOUT: .C = %C.decl
  36. // CHECK:STDOUT: .F = %F.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  39. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  40. // CHECK:STDOUT: %n.patt: %pattern_type = binding_pattern n [concrete]
  41. // CHECK:STDOUT: %n.param_patt: %pattern_type = value_param_pattern %n.patt, call_param0 [concrete]
  42. // CHECK:STDOUT: } {
  43. // CHECK:STDOUT: %n.param: %C = value_param call_param0
  44. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  45. // CHECK:STDOUT: %n: %C = bind_name n, %n.param
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: class @C;
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: fn @F(%n.param: %C) {
  52. // CHECK:STDOUT: !entry:
  53. // CHECK:STDOUT: return
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: