struct.carbon 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/class/struct.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/class/struct.carbon
  12. // ============================================================================
  13. // Declaration
  14. // ============================================================================
  15. // --- declaration.h
  16. struct Bar;
  17. // --- import_declaration.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "declaration.h";
  20. //@dump-sem-ir-begin
  21. fn MyF(bar: Cpp.Bar*);
  22. //@dump-sem-ir-end
  23. // CHECK:STDOUT: --- import_declaration.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
  27. // CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
  28. // CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
  29. // CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
  30. // CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  35. // CHECK:STDOUT: .Bar = %Bar.decl
  36. // CHECK:STDOUT: import Cpp//...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
  43. // CHECK:STDOUT: %bar.patt: %pattern_type = value_binding_pattern bar [concrete]
  44. // CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
  45. // CHECK:STDOUT: } {
  46. // CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
  47. // CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
  48. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  49. // CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
  50. // CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %bar: %ptr = value_binding bar, %bar.param
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
  57. // CHECK:STDOUT: