include_paths.carbon 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/uint.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/include_paths.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/include_paths.carbon
  12. // --- include_stddef.h
  13. // Check that include paths are properly set up when running Clang.
  14. // Clang provides <stddef.h> as a builtin header.
  15. #include <stddef.h>
  16. ptrdiff_t GetSize();
  17. inline int GetSizeAsInt() { return GetSize(); }
  18. // --- import_stddef_indirectly.carbon
  19. library "[[@TEST_NAME]]";
  20. import Cpp library "include_stddef.h";
  21. // TODO: `fn CallGetSize() -> Cpp.ptrdiff_t {`
  22. fn CallGetSize() -> i32 {
  23. // TODO: Call `Cpp.GetSize` directly once we can import the types `long` and `long long`.
  24. return Cpp.GetSizeAsInt() as i32;
  25. }
  26. // --- fail_todo_import_stddef_directly.carbon
  27. library "[[@TEST_NAME]]";
  28. import Cpp library "stddef.h";
  29. // TODO: Once we can import `unsigned long` / `unsigned long long`, this should work.
  30. // CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+7]]:8: error: semantics TODO: `Unsupported: Type declaration: size_t` [SemanticsTodo]
  31. // CHECK:STDERR: var n: Cpp.size_t = 42;
  32. // CHECK:STDERR: ^~~~~~~~~~
  33. // CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+4]]:8: note: in `Cpp` name lookup for `size_t` [InCppNameLookup]
  34. // CHECK:STDERR: var n: Cpp.size_t = 42;
  35. // CHECK:STDERR: ^~~~~~~~~~
  36. // CHECK:STDERR:
  37. var n: Cpp.size_t = 42;