basics.carbon 2.4 KB

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