bad_import.carbon 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/bad_import.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/bad_import.carbon
  12. // --- fail_import_cpp.carbon
  13. library "[[@TEST_NAME]]";
  14. // CHECK:STDERR: fail_import_cpp.carbon:[[@LINE+4]]:1: error: `Cpp` import without `library` or `inline` [CppInteropMissingLibrary]
  15. // CHECK:STDERR: import Cpp;
  16. // CHECK:STDERR: ^~~~~~~~~~~
  17. // CHECK:STDERR:
  18. import Cpp;
  19. // --- fail_import_cpp_library_empty.carbon
  20. library "[[@TEST_NAME]]";
  21. // CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+4]]:10: error: empty filename [CppInteropParseError]
  22. // CHECK:STDERR: 8 | #include ""
  23. // CHECK:STDERR: | ^
  24. // CHECK:STDERR:
  25. import Cpp library "";
  26. // --- fail_import_cpp_library_file_with_quotes.carbon
  27. library "[[@TEST_NAME]]";
  28. // CHECK:STDERR: fail_import_cpp_library_file_with_quotes.carbon:[[@LINE+4]]:10: error: '\"foo.h\"' file not found [CppInteropParseError]
  29. // CHECK:STDERR: 8 | #include "\"foo.h\""
  30. // CHECK:STDERR: | ^~~~~~~~~~~
  31. // CHECK:STDERR:
  32. import Cpp library "\"foo.h\"";
  33. // --- todo_fail_unterminated_import_inline.carbon
  34. import Cpp inline '''c++
  35. void f() {
  36. ''';
  37. // TODO: We should diagnose that the inline C++ code didn't leave us at the top
  38. // level.
  39. import Cpp inline '''c++
  40. }
  41. ''';