basics.carbon 2.2 KB

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