mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
This adds support for importing C++ code directly from source rather than via a `#include`. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/bad_import.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/bad_import.carbon
|
|
|
|
// --- fail_import_cpp.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_import_cpp.carbon:[[@LINE+4]]:1: error: `Cpp` import without `library` or `inline` [CppInteropMissingLibrary]
|
|
// CHECK:STDERR: import Cpp;
|
|
// CHECK:STDERR: ^~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
import Cpp;
|
|
|
|
// --- fail_import_cpp_library_empty.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+4]]:10: error: empty filename [CppInteropParseError]
|
|
// CHECK:STDERR: 8 | #include ""
|
|
// CHECK:STDERR: | ^
|
|
// CHECK:STDERR:
|
|
import Cpp library "";
|
|
|
|
// --- fail_import_cpp_library_file_with_quotes.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_import_cpp_library_file_with_quotes.carbon:[[@LINE+4]]:10: error: '\"foo.h\"' file not found [CppInteropParseError]
|
|
// CHECK:STDERR: 8 | #include "\"foo.h\""
|
|
// CHECK:STDERR: | ^~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
import Cpp library "\"foo.h\"";
|
|
|
|
// --- todo_fail_unterminated_import_inline.carbon
|
|
|
|
import Cpp inline '''c++
|
|
void f() {
|
|
''';
|
|
|
|
// TODO: We should diagnose that the inline C++ code didn't leave us at the top
|
|
// level.
|
|
|
|
import Cpp inline '''c++
|
|
}
|
|
''';
|