base.carbon 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/int.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/export/base.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/export/base.carbon
  12. // --- derived_to_base.carbon
  13. library "[[@TEST_NAME]]";
  14. import Cpp;
  15. base class A {}
  16. class B {
  17. extend base: A;
  18. }
  19. inline Cpp '''
  20. Carbon::A* Convert(Carbon::B* p) {
  21. return p;
  22. }
  23. ''';
  24. // --- name_lookup.carbon
  25. library "[[@TEST_NAME]]";
  26. import Cpp;
  27. base class A {
  28. fn F();
  29. fn G(n: i32);
  30. }
  31. class B {
  32. extend base: A;
  33. fn G();
  34. }
  35. inline Cpp '''
  36. void Qualified() {
  37. Carbon::B::F();
  38. Carbon::B::G();
  39. }
  40. void MemberAccess(Carbon::A *a, Carbon::B *b) {
  41. // TODO: These cause a crash.
  42. // b->F();
  43. // b->G();
  44. }
  45. ''';