export.carbon 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/namespace/export.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/namespace/export.carbon
  12. // --- other.carbon
  13. package Other;
  14. namespace Nested;
  15. namespace Nested.Again;
  16. class Class1;
  17. // --- namespace.carbon
  18. library "[[@TEST_NAME]]";
  19. import Other;
  20. import Cpp inline '''
  21. namespace X = Carbon::Other;
  22. namespace Y = Carbon::Other::Nested;
  23. namespace Z = Carbon::Other::Nested::Again;
  24. Carbon::Other::Class1 *glbl;
  25. template<typename T> void f1() {
  26. T* v;
  27. }
  28. void f2() {
  29. f1<Carbon::Other::Class1>();
  30. }
  31. ''';
  32. // --- alias_identity.carbon
  33. import Cpp;
  34. namespace M;
  35. alias N = M;
  36. class M.C {}
  37. inline Cpp '''
  38. // OK, valid redeclaration: M and N are the same namespace.
  39. namespace A = Carbon::M;
  40. namespace A = Carbon::N;
  41. // Valid: M::C and N::C are the same class.
  42. Carbon::M::C *pmc;
  43. Carbon::N::C *pnc = pmc;
  44. ''';