Introduce a Clang diagnostic instruction and use it to point to C++ source locations on Clang errors and warnings (#5262)

Introduce `ImportIRId::Cpp` and refer to clang source location in its
`ImportIRInst`.

Part of #5245.
This commit is contained in:
Boaz Brickner
2025-04-25 13:05:45 +00:00
committed by GitHub
parent 1e2d4c3405
commit 609ccefd18
29 changed files with 487 additions and 267 deletions
@@ -22,18 +22,18 @@ import Cpp;
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+4]]:1: error: `Cpp` import missing library [CppInteropMissingLibrary]
// CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+9]]:1: error: `Cpp` import missing library [CppInteropMissingLibrary]
// CHECK:STDERR: import Cpp library "";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
import Cpp library "";
// --- fail_import_cpp_library_file_with_quotes.carbon
// CHECK:STDERR: fail_import_cpp_library_file_with_quotes.carbon: error: C++:
// CHECK:STDERR: fail_import_cpp_library_file_with_quotes.carbon.generated.cpp_imports.h:1: error: C++:
// CHECK:STDERR: fail_import_cpp_library_file_with_quotes.carbon.generated.cpp_imports.h:1:10: fatal error: '\"foo.h\"' file not found
// CHECK:STDERR: 1 | #include "\"foo.h\""
// CHECK:STDERR: | ^~~~~~~~~~~
// CHECK:STDERR: [CppInteropParseError]
import Cpp library "";
// --- fail_import_cpp_library_file_with_quotes.carbon
library "[[@TEST_NAME]]";
@@ -10,15 +10,15 @@
// --- one_error.h
// CHECK:STDERR: ./one_error.h:[[@LINE+6]]: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_one_error.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error.h:[[@LINE+4]]:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
#error "error1"
// --- fail_import_cpp_file_with_one_error.carbon
// CHECK:STDERR: fail_import_cpp_file_with_one_error.carbon: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_one_error.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
library "[[@TEST_NAME]]";
@@ -30,16 +30,16 @@ import Cpp library "one_error.h";
// --- multiple_errors.h
// CHECK:STDERR: ./multiple_errors.h:[[@LINE+6]]: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors.h:[[@LINE+4]]:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
#error "error1"
#error "error2"
// --- fail_import_cpp_file_with_multiple_errors.carbon
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors.carbon: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
library "[[@TEST_NAME]]";
@@ -47,10 +47,10 @@ library "[[@TEST_NAME]]";
// CHECK:STDERR: import Cpp library "multiple_errors.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors.carbon: error: C++:
// CHECK:STDERR: ./multiple_errors.h:9: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors.h:3:2: error: "error2"
// CHECK:STDERR: 3 | #error "error2"
// CHECK:STDERR: ./multiple_errors.h:9:2: error: "error2"
// CHECK:STDERR: 9 | #error "error2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
@@ -61,15 +61,15 @@ import Cpp library "multiple_errors.h";
// --- one_warning.h
// CHECK:STDERR: ./one_warning.h:[[@LINE+6]]: warning: C++:
// CHECK:STDERR: In file included from import_cpp_file_with_one_warning.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_warning.h:[[@LINE+4]]:2: warning: "warning1"
// CHECK:STDERR: 8 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
#warning "warning1"
// --- import_cpp_file_with_one_warning.carbon
// CHECK:STDERR: import_cpp_file_with_one_warning.carbon: warning: C++:
// CHECK:STDERR: In file included from import_cpp_file_with_one_warning.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
// CHECK:STDERR: 2 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
library "[[@TEST_NAME]]";
@@ -81,17 +81,17 @@ import Cpp library "one_warning.h";
// --- multiple_warnings.h
// CHECK:STDERR: ./multiple_warnings.h:[[@LINE+6]]: warning: C++:
// CHECK:STDERR: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_warnings.h:[[@LINE+4]]:2: warning: "warning1"
// CHECK:STDERR: 8 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
#warning "warning1"
#warning "warning2"
#warning "warning3"
// --- import_cpp_file_with_multiple_warnings.carbon
// CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon: warning: C++:
// CHECK:STDERR: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_warnings.h:2:2: warning: "warning1"
// CHECK:STDERR: 2 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
library "[[@TEST_NAME]]";
@@ -99,20 +99,20 @@ library "[[@TEST_NAME]]";
// CHECK:STDERR: import Cpp library "multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_warnings.h:9: warning: C++:
// CHECK:STDERR: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_warnings.h:3:2: warning: "warning2"
// CHECK:STDERR: 3 | #warning "warning2"
// CHECK:STDERR: ./multiple_warnings.h:9:2: warning: "warning2"
// CHECK:STDERR: 9 | #warning "warning2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+14]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_warnings.h:10: warning: C++:
// CHECK:STDERR: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_warnings.h:4:2: warning: "warning3"
// CHECK:STDERR: 4 | #warning "warning3"
// CHECK:STDERR: ./multiple_warnings.h:10:2: warning: "warning3"
// CHECK:STDERR: 10 | #warning "warning3"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
@@ -123,16 +123,16 @@ import Cpp library "multiple_warnings.h";
// --- one_error_and_one_warning.h
// CHECK:STDERR: ./one_error_and_one_warning.h:[[@LINE+6]]: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_one_error_and_one_warning.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error_and_one_warning.h:[[@LINE+4]]:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
#error "error1"
#warning "warning1"
// --- fail_import_cpp_file_with_one_error_and_one_warning.carbon
// CHECK:STDERR: fail_import_cpp_file_with_one_error_and_one_warning.carbon: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_one_error_and_one_warning.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error_and_one_warning.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
library "[[@TEST_NAME]]";
@@ -140,10 +140,10 @@ library "[[@TEST_NAME]]";
// CHECK:STDERR: import Cpp library "one_error_and_one_warning.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_file_with_one_error_and_one_warning.carbon: warning: C++:
// CHECK:STDERR: ./one_error_and_one_warning.h:9: warning: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_one_error_and_one_warning.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error_and_one_warning.h:3:2: warning: "warning1"
// CHECK:STDERR: 3 | #warning "warning1"
// CHECK:STDERR: ./one_error_and_one_warning.h:9:2: warning: "warning1"
// CHECK:STDERR: 9 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_cpp_file_with_one_error_and_one_warning.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
@@ -154,6 +154,12 @@ import Cpp library "one_error_and_one_warning.h";
// --- multiple_errors_and_multiple_warnings.h
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:[[@LINE+6]]: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:[[@LINE+4]]:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
#error "error1"
#error "error2"
#warning "warning1"
@@ -161,227 +167,242 @@ import Cpp library "one_error_and_one_warning.h";
#warning "warning3"
// --- fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+44]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+50]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon: error: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:9: error: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3:2: error: "error2"
// CHECK:STDERR: 3 | #error "error2"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:9:2: error: "error2"
// CHECK:STDERR: 9 | #error "error2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+34]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+40]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:10: warning: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4:2: warning: "warning1"
// CHECK:STDERR: 4 | #warning "warning1"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:10:2: warning: "warning1"
// CHECK:STDERR: 10 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+24]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+30]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:11: warning: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5:2: warning: "warning2"
// CHECK:STDERR: 5 | #warning "warning2"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:11:2: warning: "warning2"
// CHECK:STDERR: 11 | #warning "warning2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+14]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+20]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:12: warning: C++:
// CHECK:STDERR: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6:2: warning: "warning3"
// CHECK:STDERR: 6 | #warning "warning3"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:12:2: warning: "warning3"
// CHECK:STDERR: 12 | #warning "warning3"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+10]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: ./one_warning.h:8: warning: C++:
// CHECK:STDERR: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_warning.h:8:2: warning: "warning1"
// CHECK:STDERR: 8 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
import Cpp library "multiple_errors_and_multiple_warnings.h";
// --- import_multiple_cpp_files_with_warnings.carbon
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon: warning: C++:
// CHECK:STDERR: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
// CHECK:STDERR: 2 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
library "[[@TEST_NAME]]";
import Cpp library "one_warning.h";
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+34]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+40]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_warnings.h:8: warning: C++:
// CHECK:STDERR: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_warnings.h:2:2: warning: "warning1"
// CHECK:STDERR: 2 | #warning "warning1"
// CHECK:STDERR: ./multiple_warnings.h:8:2: warning: "warning1"
// CHECK:STDERR: 8 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+24]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+30]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_warnings.h:9: warning: C++:
// CHECK:STDERR: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_warnings.h:3:2: warning: "warning2"
// CHECK:STDERR: 3 | #warning "warning2"
// CHECK:STDERR: ./multiple_warnings.h:9:2: warning: "warning2"
// CHECK:STDERR: 9 | #warning "warning2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+14]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+20]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon: warning: C++:
// CHECK:STDERR: ./multiple_warnings.h:10: warning: C++:
// CHECK:STDERR: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_warnings.h:4:2: warning: "warning3"
// CHECK:STDERR: 4 | #warning "warning3"
// CHECK:STDERR: ./multiple_warnings.h:10:2: warning: "warning3"
// CHECK:STDERR: 10 | #warning "warning3"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+10]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: ./one_error_and_one_warning.h:8: error: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error_and_one_warning.h:8:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
import Cpp library "multiple_warnings.h";
// --- fail_import_multiple_cpp_files_with_warnings_and_errors.carbon
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: error: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error_and_one_warning.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
library "[[@TEST_NAME]]";
import Cpp library "one_error_and_one_warning.h";
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+64]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+66]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: warning: C++:
// CHECK:STDERR: ./one_error_and_one_warning.h:9: warning: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_error_and_one_warning.h:3:2: warning: "warning1"
// CHECK:STDERR: 3 | #warning "warning1"
// CHECK:STDERR: ./one_error_and_one_warning.h:9:2: warning: "warning1"
// CHECK:STDERR: 9 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+54]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+56]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: error: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:8: error: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:8:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+44]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+46]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: error: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:9: error: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3:2: error: "error2"
// CHECK:STDERR: 3 | #error "error2"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:9:2: error: "error2"
// CHECK:STDERR: 9 | #error "error2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+34]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+36]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: warning: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:10: warning: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4:2: warning: "warning1"
// CHECK:STDERR: 4 | #warning "warning1"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:10:2: warning: "warning1"
// CHECK:STDERR: 10 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+24]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+26]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: warning: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:11: warning: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5:2: warning: "warning2"
// CHECK:STDERR: 5 | #warning "warning2"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:11:2: warning: "warning2"
// CHECK:STDERR: 11 | #warning "warning2"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+14]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+16]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon: warning: C++:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:12: warning: C++:
// CHECK:STDERR: In file included from fail_import_multiple_cpp_files_with_warnings_and_errors.carbon.generated.cpp_imports.h:2:
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6:2: warning: "warning3"
// CHECK:STDERR: 6 | #warning "warning3"
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:12:2: warning: "warning3"
// CHECK:STDERR: 12 | #warning "warning3"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_multiple_cpp_files_with_warnings_and_errors.carbon:[[@LINE+6]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "multiple_errors_and_multiple_warnings.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: ./one_error.h:8: error: C++:
// CHECK:STDERR: In file included from fail_import_indirect_error.carbon.generated.cpp_imports.h:1:
import Cpp library "multiple_errors_and_multiple_warnings.h";
// --- indirect_error.h
// CHECK:STDERR: In file included from ./indirect_error.h:[[@LINE+5]]:
// CHECK:STDERR: ./one_error.h:8:2: error: "error1"
// CHECK:STDERR: 8 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
#include "one_error.h"
// --- fail_import_indirect_error.carbon
// CHECK:STDERR: fail_import_indirect_error.carbon: error: C++:
// CHECK:STDERR: In file included from fail_import_indirect_error.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: In file included from ./indirect_error.h:2:
// CHECK:STDERR: ./one_error.h:2:2: error: "error1"
// CHECK:STDERR: 2 | #error "error1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseError]
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_import_indirect_error.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: fail_import_indirect_error.carbon:[[@LINE+6]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "indirect_error.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: ./one_warning.h:8: warning: C++:
// CHECK:STDERR: In file included from import_indirect_warning.carbon.generated.cpp_imports.h:1:
import Cpp library "indirect_error.h";
// --- indirect_warning.h
// CHECK:STDERR: In file included from ./indirect_warning.h:[[@LINE+5]]:
// CHECK:STDERR: ./one_warning.h:8:2: warning: "warning1"
// CHECK:STDERR: 8 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
#include "one_warning.h"
// --- import_indirect_warning.carbon
// CHECK:STDERR: import_indirect_warning.carbon: warning: C++:
// CHECK:STDERR: In file included from import_indirect_warning.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: In file included from ./indirect_warning.h:2:
// CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
// CHECK:STDERR: 2 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
library "[[@TEST_NAME]]";
// CHECK:STDERR: import_indirect_warning.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import_indirect_warning.carbon:[[@LINE+10]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "indirect_warning.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: ./one_warning.h:8: warning: C++:
// CHECK:STDERR: In file included from fail_import_cpp_library_lexer_error.carbon.generated.cpp_imports.h:1:
// CHECK:STDERR: ./one_warning.h:8:2: warning: "warning1"
// CHECK:STDERR: 8 | #warning "warning1"
// CHECK:STDERR: | ^
// CHECK:STDERR: [CppInteropParseWarning]
import Cpp library "indirect_warning.h";
// --- fail_import_cpp_library_lexer_error.carbon
library "[[@TEST_NAME]]"; // Trailing comment
// TODO: Move this warning to be after the lexer trailing comment error.
// CHECK:STDERR: fail_import_cpp_library_lexer_error.carbon:[[@LINE+8]]:1: note: in `Cpp` import [InCppImport]
// CHECK:STDERR: import Cpp library "one_warning.h";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_import_cpp_library_lexer_error.carbon:[[@LINE-7]]:44: error: trailing comments are not permitted [TrailingComment]
// CHECK:STDERR: library "import_cpp_library_lexer_error"; // Trailing comment
// CHECK:STDERR: ^
// CHECK:STDERR:
import Cpp library "one_warning.h";
// CHECK:STDOUT: --- fail_import_cpp_file_with_one_error.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -560,3 +581,20 @@ import Cpp library "indirect_warning.h";
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_import_cpp_library_lexer_error.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
// CHECK:STDOUT: import Cpp//...
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Cpp = imports.%Cpp
// CHECK:STDOUT: }
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
// CHECK:STDOUT: import Cpp "one_warning.h"
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -7,14 +7,14 @@
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/no_prelude/file_not_found.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/no_prelude/file_not_found.carbon
// --- fail_cpp_file_not_found.carbon
// CHECK:STDERR: fail_cpp_file_not_found.carbon: error: C++:
// CHECK:STDERR: fail_cpp_file_not_found.carbon.generated.cpp_imports.h:1: error: C++:
// CHECK:STDERR: fail_cpp_file_not_found.carbon.generated.cpp_imports.h:1:10: fatal error: 'not_found.h' file not found
// CHECK:STDERR: 1 | #include "not_found.h"
// CHECK:STDERR: | ^~~~~~~~~~~~~
// CHECK:STDERR: [CppInteropParseError]
// --- fail_cpp_file_not_found.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_cpp_file_not_found.carbon:[[@LINE+4]]:1: note: in `Cpp` import [InCppImport]