mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-25 19:11:11 +00:00
Switch tests to use the rendered form of diagnostics (#8070)
Historically, we disabled the rendered form in tests outside of `toolchain/diagnostics`. The idea was to keep tests shorter and avoid very long chains of autoupdate before stabilizing due to all the line numbers and other artifacts in the rendered form. This PR adds `--diagnostic-line-numbers=[all|first]` and defaults to `first` in tests. This keeps the rendered form so that we can easily code review that form and the visual cues it does or doesn't provide. But it removes all but the first location's line numbers to provide significantly more stability in tests. By default, tests get the full unicode line-drawing form of diagnostics so we can ensure all of the artifacts there make sense with the specific case being diagnosed, but we do retain some focused ASCII-rendering tests to ensure that fallback remains usable. There are some issues here that will be fixed in subsequent PRs. Notably, we try to keep the frame together in the check lines, and so force some parts to use the first location. This largely works, but fails in some edge cases, causing the entire frame to be located incorrectly. There is a TODO about this that we need to fix, and it only occurs 6 times across the test suite, so it didn't seem worth front-loading a fix for here. Assisted-by: Claude Code
This commit is contained in:
1 parent
0b7059a360
commit
d0badecd2a
888 files changed
+39731
-12799
No files matched your search
+262
-108
@@ -16,15 +16,19 @@
|
||||
|
||||
// --- one_error.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_one_error.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./one_error.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
|
||||
// --- fail_import_cpp_file_with_one_error.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_one_error.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./one_error.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "one_error.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -33,19 +37,27 @@ import Cpp library "one_error.h";
|
||||
|
||||
// --- multiple_errors.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error2" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error2"
|
||||
|
||||
// --- fail_import_cpp_file_with_multiple_errors.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors.h:3:2: error: "error2" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multiple_errors.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -54,6 +66,13 @@ import Cpp library "multiple_errors.h";
|
||||
|
||||
// --- one_warning.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_cpp_file_with_one_warning.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
|
||||
// --- import_cpp_file_with_one_warning.carbon
|
||||
@@ -61,9 +80,6 @@ import Cpp library "multiple_errors.h";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: included from: import_cpp_file_with_one_warning.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "one_warning.h";
|
||||
//@dump-sem-ir-end
|
||||
|
||||
@@ -73,8 +89,29 @@ import Cpp library "one_warning.h";
|
||||
|
||||
// --- multiple_warnings.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_cpp_file_with_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_cpp_file_with_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning2"
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_cpp_file_with_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning3"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning3"
|
||||
|
||||
// --- import_cpp_file_with_multiple_warnings.carbon
|
||||
@@ -82,15 +119,6 @@ import Cpp library "one_warning.h";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: included from: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+9]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_warnings.h:2:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_warnings.h:3:2: warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_warnings.h:4:2: warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multiple_warnings.h";
|
||||
//@dump-sem-ir-end
|
||||
|
||||
@@ -100,19 +128,27 @@ import Cpp library "multiple_warnings.h";
|
||||
|
||||
// --- one_error_and_one_warning.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_one_error_and_one_warning.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./one_error_and_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_one_error_and_one_warning.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./one_error_and_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
|
||||
// --- fail_import_cpp_file_with_one_error_and_one_warning.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_one_error_and_one_warning.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./one_error_and_one_warning.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_one_error_and_one_warning.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./one_error_and_one_warning.h:3:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "one_error_and_one_warning.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -121,31 +157,51 @@ import Cpp library "one_error_and_one_warning.h";
|
||||
|
||||
// --- multiple_errors_and_multiple_warnings.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error2" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error2"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning2"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning3"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning3"
|
||||
|
||||
// --- fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+15]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+12]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3:2: error: "error2" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+9]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5:2: warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6:2: warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multiple_errors_and_multiple_warnings.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -154,12 +210,40 @@ import Cpp library "multiple_errors_and_multiple_warnings.h";
|
||||
|
||||
// --- multi_one_warning.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_multiple_cpp_files_with_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
|
||||
// --- multi_multiple_warnings.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_multiple_cpp_files_with_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_multiple_cpp_files_with_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning2"
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_multiple_cpp_files_with_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning3"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning3"
|
||||
|
||||
// --- import_multiple_cpp_files_with_warnings.carbon
|
||||
@@ -167,19 +251,7 @@ import Cpp library "multiple_errors_and_multiple_warnings.h";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: included from: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_one_warning.h:2:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multi_one_warning.h";
|
||||
// CHECK:STDERR: included from: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+9]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_warnings.h:2:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_warnings.h:3:2: warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_warnings.h:4:2: warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multi_multiple_warnings.h";
|
||||
//@dump-sem-ir-end
|
||||
|
||||
@@ -189,43 +261,71 @@ import Cpp library "multi_multiple_warnings.h";
|
||||
|
||||
// --- multi_one_error_and_one_warning.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_one_error_and_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_one_error_and_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
|
||||
// --- multi_multiple_errors_and_multiple_warnings.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error2" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error2"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning2"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning2"
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./multi_multiple_errors_and_multiple_warnings.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning3"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning3"
|
||||
|
||||
// --- fail_import_multiple_cpp_files_with_errors_and_warnings.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_one_error_and_one_warning.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_one_error_and_one_warning.h:3:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multi_one_error_and_one_warning.h";
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+15]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_errors_and_multiple_warnings.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+12]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_errors_and_multiple_warnings.h:3:2: error: "error2" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+9]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_errors_and_multiple_warnings.h:4:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+6]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_errors_and_multiple_warnings.h:5:2: warning: "warning2" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+3]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./multi_multiple_errors_and_multiple_warnings.h:6:2: warning: "warning3" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "multi_multiple_errors_and_multiple_warnings.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -234,6 +334,14 @@ import Cpp library "multi_multiple_errors_and_multiple_warnings.h";
|
||||
|
||||
// --- indirect_one_error.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_indirect_error.carbon [InCppInclude]
|
||||
// CHECK:STDERR: │ ├── included from: ./indirect_error.h [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./indirect_one_error.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #error "error1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#error "error1"
|
||||
|
||||
// --- indirect_error.h
|
||||
@@ -244,10 +352,6 @@ import Cpp library "multi_multiple_errors_and_multiple_warnings.h";
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_indirect_error.carbon:[[@LINE+4]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: included from: ./indirect_error.h:2:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./indirect_one_error.h:2:2: error: "error1" [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "indirect_error.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -256,6 +360,14 @@ import Cpp library "indirect_error.h";
|
||||
|
||||
// --- indirect_one_warning.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_indirect_warning.carbon [InCppInclude]
|
||||
// CHECK:STDERR: │ ├── included from: ./indirect_warning.h [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./indirect_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
|
||||
// --- indirect_warning.h
|
||||
@@ -267,10 +379,6 @@ import Cpp library "indirect_error.h";
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: included from: import_indirect_warning.carbon:[[@LINE+4]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: included from: ./indirect_warning.h:2:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./indirect_one_warning.h:2:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "indirect_warning.h";
|
||||
//@dump-sem-ir-end
|
||||
|
||||
@@ -280,20 +388,29 @@ import Cpp library "indirect_warning.h";
|
||||
|
||||
// --- lexer_error_one_warning.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_cpp_library_lexer_error.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./lexer_error_one_warning.h:[[@LINE+6]]:2
|
||||
// CHECK:STDERR: -> │ #warning "warning1"
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
#warning "warning1"
|
||||
|
||||
// --- fail_import_cpp_library_lexer_error.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_lexer_error.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ //!Lexer error: whitespace is required after the comment introducer.
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: whitespace is required after '//'
|
||||
// CHECK:STDERR: · ┃ [NoWhitespaceAfterCommentIntroducer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
//!Lexer error: whitespace is required after the comment introducer.
|
||||
|
||||
// TODO: Move this warning to be after the lexer error.
|
||||
// CHECK:STDERR: included from: fail_import_cpp_library_lexer_error.carbon:[[@LINE+5]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./lexer_error_one_warning.h:2:2: warning: "warning1" [CppInteropParseWarning]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_import_cpp_library_lexer_error.carbon:[[@LINE-6]]:3: error: whitespace is required after '//' [NoWhitespaceAfterCommentIntroducer]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "lexer_error_one_warning.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -302,20 +419,30 @@ import Cpp library "lexer_error_one_warning.h";
|
||||
|
||||
// --- fix_it_hints.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_fix_it_hints.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./fix_it_hints.h:[[@LINE+8]]:19
|
||||
// CHECK:STDERR: -> │ double score = 0.1
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected ';' after top level declarator
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: · ╰────┤ insert `;` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
double score = 0.1
|
||||
|
||||
// --- fail_import_fix_it_hints.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_import_fix_it_hints.carbon:[[@LINE+4]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./fix_it_hints.h:2:19: error: expected ';' after top level declarator [CppInteropParseError]
|
||||
// CHECK:STDERR: ./fix_it_hints.h:2:19: note: insert `;` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "fix_it_hints.h";
|
||||
|
||||
fn F() {
|
||||
// CHECK:STDERR: fail_import_fix_it_hints.carbon:[[@LINE+2]]:3-9: error: member name `foo` not found in `Cpp` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_fix_it_hints.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ Cpp.foo();
|
||||
// CHECK:STDERR: · ━━━┳━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: member name `foo` not found in `Cpp`
|
||||
// CHECK:STDERR: · ┃ [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Cpp.foo();
|
||||
}
|
||||
@@ -329,6 +456,20 @@ fn F() {
|
||||
void foobar(int);
|
||||
|
||||
inline void call_foobar() {
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_with_notes.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./with_notes.h:[[@LINE+13]]:3
|
||||
// CHECK:STDERR: │ void foobar(int);
|
||||
// CHECK:STDERR: · ┬ ─┬─
|
||||
// CHECK:STDERR: · ╰──────────┤ candidate function not viable [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ requires 1 argument, but 2 were provided
|
||||
// CHECK:STDERR: · │ [CppInteropParseNoteReason]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ foobar(1, 2);
|
||||
// CHECK:STDERR: · ━━━┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'foobar'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
foobar(1, 2);
|
||||
}
|
||||
|
||||
@@ -336,11 +477,6 @@ inline void call_foobar() {
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_with_notes.carbon:[[@LINE+5]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./with_notes.h:5:3-8: error: no matching function for call to 'foobar' [CppInteropParseError]
|
||||
// CHECK:STDERR: ./with_notes.h:2:6: note: candidate function not viable [CppInteropParseNote]
|
||||
// CHECK:STDERR: ./with_notes.h:2:13-15: note: requires 1 argument, but 2 were provided [CppInteropParseNoteReason]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "with_notes.h";
|
||||
|
||||
fn F() {
|
||||
@@ -356,6 +492,17 @@ fn F() {
|
||||
#define FOO BAR
|
||||
#define BAZ void f(error);
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_use_context_stack.carbon [InCppInclude]
|
||||
// CHECK:STDERR: │ ├── included from: ./direct_include.h [InCppInclude]
|
||||
// CHECK:STDERR: │ ├── expanded from macro defined at: ./indirect_include.h [InCppMacroExpansion]
|
||||
// CHECK:STDERR: │ ├── expanded from macro defined at: ./direct_include.h [InCppMacroExpansion]
|
||||
// CHECK:STDERR: │ ├── expanded from macro defined at: ./indirect_include.h [InCppMacroExpansion]
|
||||
// CHECK:STDERR: ├─┤ ./indirect_include.h:[[@LINE+6]]:1
|
||||
// CHECK:STDERR: -> │ #define BAZ void f(error);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: unknown type name 'error' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
FOO
|
||||
|
||||
// --- direct_include.h
|
||||
@@ -368,13 +515,6 @@ FOO
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_use_context_stack.carbon:[[@LINE+7]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: included from: ./direct_include.h:4:10 [InCppInclude]
|
||||
// CHECK:STDERR: expanded from macro defined at: ./indirect_include.h:2:13 [InCppMacroExpansion]
|
||||
// CHECK:STDERR: expanded from macro defined at: ./direct_include.h:2:13 [InCppMacroExpansion]
|
||||
// CHECK:STDERR: expanded from macro defined at: ./indirect_include.h:3:20 [InCppMacroExpansion]
|
||||
// CHECK:STDERR: ./indirect_include.h:5:1: error: unknown type name 'error' [CppInteropParseError]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "direct_include.h";
|
||||
|
||||
// ============================================================================
|
||||
@@ -385,7 +525,12 @@ import Cpp library "direct_include.h";
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_loc_in_inline_simple.carbon:[[@LINE+2]]:9-14: error: use of undeclared identifier 'banana' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_loc_in_inline_simple.carbon:[[@LINE+7]]:9
|
||||
// CHECK:STDERR: -> │ int n = banana;
|
||||
// CHECK:STDERR: · ━━━┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: use of undeclared identifier 'banana'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp inline "int n = banana;";
|
||||
|
||||
@@ -393,8 +538,17 @@ import Cpp inline "int n = banana;";
|
||||
|
||||
import Cpp inline '''c++
|
||||
void f(const int n) {
|
||||
// CHECK:STDERR: fail_loc_in_inline_block.carbon:[[@LINE+3]]:3: error: cannot assign to variable 'n' with const-qualified type 'const int' [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_loc_in_inline_block.carbon:[[@LINE-2]]:8-18: note: variable 'n' declared const here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_loc_in_inline_block.carbon:[[@LINE+12]]:3
|
||||
// CHECK:STDERR: │ void f(const int n) {
|
||||
// CHECK:STDERR: · ─────┬─────
|
||||
// CHECK:STDERR: · ╰──┤ variable 'n' declared const here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ ++n;
|
||||
// CHECK:STDERR: · ┳ ─
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot assign to variable 'n' with const-qualified type 'const
|
||||
// CHECK:STDERR: · ┃ int'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
++n;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/fail_import_fix_its.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/fail_import_fix_its.carbon
|
||||
// CHECK:STDERR: ╭─┤ <carbon Cpp imports>:1:1
|
||||
// CHECK:STDERR: -> │ ;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: extra ';' outside of a function is incompatible with C++98
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseWarning]
|
||||
// CHECK:STDERR: · ╰────┤ remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
|
||||
// Covers the three shapes a Clang fix-it comes in, each of which becomes a
|
||||
// label saying what to do rather than the inline rendering Clang would draw.
|
||||
@@ -21,52 +29,80 @@
|
||||
// --- replacement.h
|
||||
|
||||
int variable_name;
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_replacement.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./replacement.h:[[@LINE+21]]:13
|
||||
// CHECK:STDERR: │ int variable_name;
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ 'variable_name' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ int other = varable_name;
|
||||
// CHECK:STDERR: · ┳━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: use of undeclared identifier 'varable_name'; did you
|
||||
// CHECK:STDERR: · │ ┃ mean 'variable_name'?
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: · ╰────┤ replace with `variable_name` [CppInteropFixItReplacement]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: ╭─┤ <carbon Cpp imports>:1:1
|
||||
// CHECK:STDERR: -> │ ;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: extra ';' outside of a function is incompatible with C++98
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseWarning]
|
||||
// CHECK:STDERR: · ╰────┤ remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
int other = varable_name;
|
||||
|
||||
// --- fail_import_replacement.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: warning: extra ';' outside of a function is incompatible with C++98 [CppInteropParseWarning]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_replacement.carbon:[[@LINE+5]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./replacement.h:3:13-24: error: use of undeclared identifier 'varable_name'; did you mean 'variable_name'? [CppInteropParseError]
|
||||
// CHECK:STDERR: ./replacement.h:3:13-24: note: replace with `variable_name` [CppInteropFixItReplacement]
|
||||
// CHECK:STDERR: ./replacement.h:2:5: note: 'variable_name' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "replacement.h";
|
||||
|
||||
// --- removal.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: import_removal.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./removal.h:[[@LINE+17]]:25
|
||||
// CHECK:STDERR: -> │ struct WithExtraSemi {};;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: extra ';' outside of a function is
|
||||
// CHECK:STDERR: · │ ┃ incompatible with C++98
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseWarning]
|
||||
// CHECK:STDERR: · ╰────┤ remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: ╭─┤ <carbon Cpp imports>:1:1
|
||||
// CHECK:STDERR: -> │ ;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: extra ';' outside of a function is incompatible with C++98
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseWarning]
|
||||
// CHECK:STDERR: · ╰────┤ remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
struct WithExtraSemi {};;
|
||||
|
||||
// --- import_removal.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: warning: extra ';' outside of a function is incompatible with C++98 [CppInteropParseWarning]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: import_removal.carbon:[[@LINE+4]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./removal.h:2:25: warning: extra ';' outside of a function is incompatible with C++98 [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ./removal.h:2:25: note: remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "removal.h";
|
||||
|
||||
// --- insertion.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_import_insertion.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./insertion.h:[[@LINE+9]]:31
|
||||
// CHECK:STDERR: -> │ double missing_semicolon = 0.1
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected ';' after top level
|
||||
// CHECK:STDERR: · │ ┃ declarator
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: · ╰────┤ insert `;` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
double missing_semicolon = 0.1
|
||||
|
||||
// --- fail_import_insertion.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: warning: extra ';' outside of a function is incompatible with C++98 [CppInteropParseWarning]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: remove this [CppInteropFixItRemoval]
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: included from: fail_import_insertion.carbon:[[@LINE+4]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./insertion.h:2:31: error: expected ';' after top level declarator [CppInteropParseError]
|
||||
// CHECK:STDERR: ./insertion.h:2:31: note: insert `;` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "insertion.h";
|
||||
@@ -9,20 +9,32 @@
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/bad_import.carbon
|
||||
// CHECK:STDERR: ╭─┤ <carbon Cpp imports>:1:2
|
||||
// CHECK:STDERR: -> │ ;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected '}' [CppInteropParseError]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: ├─┤ fail_unterminated_import_inline.carbon
|
||||
// CHECK:STDERR: │ void f() {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ to match this '{' [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
|
||||
// --- fail_unterminated_import_inline.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp inline '''c++
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:2: error: expected '}' [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_unterminated_import_inline.carbon:[[@LINE+2]]:10: note: to match this '{' [CppInteropParseNote]
|
||||
// CHECK:STDERR:
|
||||
void f() {
|
||||
''';
|
||||
|
||||
import Cpp inline '''c++
|
||||
// CHECK:STDERR: fail_unterminated_import_inline.carbon:[[@LINE+2]]:1: error: extraneous closing brace ('}') [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_unterminated_import_inline.carbon:[[@LINE+6]]:1
|
||||
// CHECK:STDERR: -> │ }
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: extraneous closing brace ('}') [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
}
|
||||
''';
|
||||
@@ -31,9 +43,21 @@ import Cpp inline '''c++
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_without_name_and_inline_without_content.carbon:[[@LINE+4]]:19: error: expected a string literal to specify the library name [ExpectedLibraryName]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_without_name_and_inline_without_content.carbon:[[@LINE+16]]:19
|
||||
// CHECK:STDERR: -> │ import Cpp library inline;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected a string literal to specify the library
|
||||
// CHECK:STDERR: · ┃ name
|
||||
// CHECK:STDERR: · ┃ [ExpectedLibraryName]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_import_cpp_library_without_name_and_inline_without_content.carbon:[[@LINE+2]]:20-25: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_without_name_and_inline_without_content.carbon:[[@LINE+8]]:20
|
||||
// CHECK:STDERR: -> │ import Cpp library inline;
|
||||
// CHECK:STDERR: · ┳━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO:
|
||||
// CHECK:STDERR: · ┃ `handle invalid parse trees in `check``
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library inline;
|
||||
|
||||
@@ -41,9 +65,19 @@ import Cpp library inline;
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_with_name_and_inline_without_content.carbon:[[@LINE+4]]:27: error: `import` declarations must end with a `;` [ExpectedDeclSemi]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_with_name_and_inline_without_content.carbon:[[@LINE+14]]:27
|
||||
// CHECK:STDERR: -> │ import Cpp library "foo.h" inline;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: `import` declarations must end with a `;`
|
||||
// CHECK:STDERR: · ┃ [ExpectedDeclSemi]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_import_cpp_library_with_name_and_inline_without_content.carbon:[[@LINE+2]]:1-34: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_with_name_and_inline_without_content.carbon:[[@LINE+7]]:1
|
||||
// CHECK:STDERR: -> │ import Cpp library "foo.h" inline;
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `handle invalid parse trees in `check``
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "foo.h" inline;
|
||||
|
||||
@@ -51,9 +85,21 @@ import Cpp library "foo.h" inline;
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_without_name_and_inline_with_content.carbon:[[@LINE+4]]:19: error: expected a string literal to specify the library name [ExpectedLibraryName]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_without_name_and_inline_with_content.carbon:[[@LINE+16]]:19
|
||||
// CHECK:STDERR: -> │ import Cpp library inline "";
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected a string literal to specify the library
|
||||
// CHECK:STDERR: · ┃ name
|
||||
// CHECK:STDERR: · ┃ [ExpectedLibraryName]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_import_cpp_library_without_name_and_inline_with_content.carbon:[[@LINE+2]]:20-25: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_without_name_and_inline_with_content.carbon:[[@LINE+8]]:20
|
||||
// CHECK:STDERR: -> │ import Cpp library inline "";
|
||||
// CHECK:STDERR: · ┳━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO:
|
||||
// CHECK:STDERR: · ┃ `handle invalid parse trees in `check``
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library inline "";
|
||||
|
||||
@@ -61,8 +107,18 @@ import Cpp library inline "";
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_with_name_and_inline_with_content.carbon:[[@LINE+4]]:27: error: `import` declarations must end with a `;` [ExpectedDeclSemi]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_with_name_and_inline_with_content.carbon:[[@LINE+14]]:27
|
||||
// CHECK:STDERR: -> │ import Cpp library "foo.h" inline "";
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: `import` declarations must end with a `;`
|
||||
// CHECK:STDERR: · ┃ [ExpectedDeclSemi]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_import_cpp_library_with_name_and_inline_with_content.carbon:[[@LINE+2]]:1-37: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_with_name_and_inline_with_content.carbon:[[@LINE+7]]:1
|
||||
// CHECK:STDERR: -> │ import Cpp library "foo.h" inline "";
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `handle invalid parse trees in `check``
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "foo.h" inline "";
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_import_cpp_library_empty.carbon:[[@LINE+2]]:10: error: empty filename [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_cpp_library_empty.carbon:[[@LINE+6]]:10
|
||||
// CHECK:STDERR: -> │ #include ""
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: empty filename [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "";
|
||||
+20
-5
@@ -20,12 +20,27 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: Translate the file to a `#include` that includes the named file
|
||||
// properly. `\` escapes aren't processed in regular `#include`s.
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+8]]:10-12: error: '\' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+23]]:10
|
||||
// CHECK:STDERR: -> │ #include "\"foo.h\""
|
||||
// CHECK:STDERR: · ━┳━
|
||||
// CHECK:STDERR: · ┗━━┫ error: '\' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+6]]:13: error: invalid suffix on literal; C++11 requires a space between literal and identifier [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+5]]:13: note: insert ` ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+17]]:13
|
||||
// CHECK:STDERR: -> │ #include "\"foo.h\""
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: invalid suffix on literal; C++11 requires a space
|
||||
// CHECK:STDERR: · │ ┃ between literal and identifier
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: · ╰────┤ insert ` ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+3]]:13: warning: extra tokens at end of #include directive [CppInteropParseWarning]
|
||||
// CHECK:STDERR: fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+2]]:13: note: insert `//` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_import_cpp_library_file_with_quotes.carbon:[[@LINE+8]]:13
|
||||
// CHECK:STDERR: -> │ #include "\"foo.h\""
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: extra tokens at end of #include directive
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseWarning]
|
||||
// CHECK:STDERR: · ╰────┤ insert `//` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "\"foo.h\"";
|
||||
+5
-1
@@ -18,6 +18,10 @@
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_cpp_file_not_found.carbon:[[@LINE+2]]:10-22: error: 'not_found.h' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_cpp_file_not_found.carbon:[[@LINE+6]]:10
|
||||
// CHECK:STDERR: -> │ #include "not_found.h"
|
||||
// CHECK:STDERR: · ━━━━━━┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: 'not_found.h' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "not_found.h";
|
||||
@@ -20,7 +20,13 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "header.h";
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE+2]]:11-13: error: `namespace` introducer should be followed by a name; prefix reserved word with `r#` to form a valid identifier [ExpectedDeclName]
|
||||
// CHECK:STDERR: ╭─┤ fail_duplicate_cpp_name.carbon:[[@LINE+8]]:11
|
||||
// CHECK:STDERR: -> │ namespace Cpp;
|
||||
// CHECK:STDERR: · ┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `namespace` introducer should be followed by a name;
|
||||
// CHECK:STDERR: · ┃ prefix reserved word with `r#` to form a valid identifier
|
||||
// CHECK:STDERR: · ┃ [ExpectedDeclName]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
namespace Cpp;
|
||||
|
||||
@@ -31,7 +37,13 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "header.h";
|
||||
|
||||
namespace N;
|
||||
// CHECK:STDERR: fail_cpp_in_inner_namespace.carbon:[[@LINE+2]]:13-15: error: `.` should be followed by a name; prefix reserved word with `r#` to form a valid identifier [ExpectedDeclNameAfterPeriod]
|
||||
// CHECK:STDERR: ╭─┤ fail_cpp_in_inner_namespace.carbon:[[@LINE+8]]:13
|
||||
// CHECK:STDERR: -> │ namespace N.Cpp;
|
||||
// CHECK:STDERR: · ┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `.` should be followed by a name; prefix reserved word
|
||||
// CHECK:STDERR: · ┃ with `r#` to form a valid identifier
|
||||
// CHECK:STDERR: · ┃ [ExpectedDeclNameAfterPeriod]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
namespace N.Cpp;
|
||||
|
||||
@@ -51,9 +63,19 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "header.h";
|
||||
|
||||
// CHECK:STDERR: fail_add_name_to_cpp_namespace.carbon:[[@LINE+4]]:7-9: error: `class` introducer should be followed by a name; prefix reserved word with `r#` to form a valid identifier [ExpectedDeclName]
|
||||
// CHECK:STDERR: ╭─┤ fail_add_name_to_cpp_namespace.carbon:[[@LINE+14]]:7
|
||||
// CHECK:STDERR: -> │ class Cpp.C {};
|
||||
// CHECK:STDERR: · ┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `class` introducer should be followed by a name; prefix
|
||||
// CHECK:STDERR: · ┃ reserved word with `r#` to form a valid identifier
|
||||
// CHECK:STDERR: · ┃ [ExpectedDeclName]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_add_name_to_cpp_namespace.carbon:[[@LINE+2]]:7-9: error: name `r#Cpp` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╭─┤ fail_add_name_to_cpp_namespace.carbon:[[@LINE+6]]:7
|
||||
// CHECK:STDERR: -> │ class Cpp.C {};
|
||||
// CHECK:STDERR: · ━┳━
|
||||
// CHECK:STDERR: · ┗━━┫ error: name `r#Cpp` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
class Cpp.C {};
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/fail_fuzzing.carbon
|
||||
|
||||
// CHECK:STDERR: fail_fuzzing.carbon:[[@LINE+2]]:1-28: error: `Cpp` import found during fuzzing [CppInteropFuzzing]
|
||||
// CHECK:STDERR: ╭─┤ fail_fuzzing.carbon:[[@LINE+6]]:1
|
||||
// CHECK:STDERR: -> │ import Cpp library "file.h";
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━┳━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `Cpp` import found during fuzzing [CppInteropFuzzing]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import Cpp library "file.h";
|
||||
@@ -16,6 +16,17 @@
|
||||
|
||||
// --- struct.h
|
||||
|
||||
// CHECK:STDERR: ╷ ╭── imported from: fail_todo_import_struct_api.carbon [InImport]
|
||||
// CHECK:STDERR: │ ├── included from: struct_api.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./struct.h:[[@LINE+9]]:8
|
||||
// CHECK:STDERR: -> │ struct MyStruct { void Foo(); };
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┏━━━━━━┛
|
||||
// CHECK:STDERR: · ┃ error: semantics TODO:
|
||||
// CHECK:STDERR: · ┃ `indirect import of C++ declaration with no direct Cpp import`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
struct MyStruct { void Foo(); };
|
||||
|
||||
// --- struct_api.carbon
|
||||
@@ -30,10 +41,6 @@ alias MyStructAlias = Cpp.MyStruct;
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: imported from: fail_todo_import_struct_api.carbon:[[@LINE+4]]:1 [InImport]
|
||||
// CHECK:STDERR: included from: struct_api.carbon:4:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./struct.h:2:8: error: semantics TODO: `indirect import of C++ declaration with no direct Cpp import` [SemanticsTodo]
|
||||
// CHECK:STDERR:
|
||||
import library "struct_api";
|
||||
|
||||
fn F() {
|
||||
|
||||
@@ -89,9 +89,19 @@ namespace A {
|
||||
fn TryToUseNotLeaked() {
|
||||
// TODO: Clang's diagnostic for using a class whose definition is not
|
||||
// reachable is confusing.
|
||||
// CHECK:STDERR: fail_not_leaked.carbon:[[@LINE+4]]:17-23: error: binding pattern has incomplete type `X` in name binding declaration [IncompleteTypeInBindingDecl]
|
||||
// CHECK:STDERR: included from: direct_import.carbon:4:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./shared.h:3:10: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR: ╭─┤ fail_not_leaked.carbon:[[@LINE+14]]:17
|
||||
// CHECK:STDERR: -> │ var unused x: Cpp.A.X = 0;
|
||||
// CHECK:STDERR: · ┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: binding pattern has incomplete type `X` in name
|
||||
// CHECK:STDERR: · ┃ binding declaration
|
||||
// CHECK:STDERR: · ┃ [IncompleteTypeInBindingDecl]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: │ ╭── included from: direct_import.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./shared.h
|
||||
// CHECK:STDERR: │ struct X {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
var unused x: Cpp.A.X = 0;
|
||||
}
|
||||
|
||||
+61
-11
@@ -45,8 +45,15 @@ void f() {}
|
||||
''';
|
||||
|
||||
inline Cpp '''
|
||||
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE+3]]:6: error: redefinition of 'f' [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE-5]]:6: note: previous definition is here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_redefinition.carbon:[[@LINE+10]]:6
|
||||
// CHECK:STDERR: │ void f() {}
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ previous definition is here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ void f() {}
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: redefinition of 'f' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
void f() {}
|
||||
''';
|
||||
@@ -57,13 +64,23 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp;
|
||||
|
||||
// CHECK:STDERR: fail_diag_location.carbon:[[@LINE+2]]:12-21: error: use of undeclared identifier 'undeclared' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_diag_location.carbon:[[@LINE+7]]:12
|
||||
// CHECK:STDERR: -> │ void f() { undeclared = 0; }
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: use of undeclared identifier 'undeclared'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "void f() { undeclared = 0; }";
|
||||
|
||||
inline Cpp '''
|
||||
void g() {
|
||||
// CHECK:STDERR: fail_diag_location.carbon:[[@LINE+2]]:3-12: error: use of undeclared identifier 'undeclared' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_diag_location.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ undeclared = 0;
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: use of undeclared identifier 'undeclared'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
undeclared = 0;
|
||||
}
|
||||
@@ -73,7 +90,11 @@ void g() {
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_inline_no_import.carbon:[[@LINE+2]]:8-10: error: name `Cpp` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╭─┤ fail_inline_no_import.carbon:[[@LINE+6]]:8
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━┳━
|
||||
// CHECK:STDERR: · ┗━━┫ error: name `Cpp` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "";
|
||||
|
||||
@@ -84,25 +105,45 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
class C {
|
||||
// CHECK:STDERR: fail_nested.carbon:[[@LINE+2]]:3-16: error: `inline Cpp` declaration not at file scope [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━━━━━━━┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `inline Cpp` declaration not at file scope
|
||||
// CHECK:STDERR: · ┃ [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "";
|
||||
}
|
||||
|
||||
interface I {
|
||||
// CHECK:STDERR: fail_nested.carbon:[[@LINE+2]]:3-16: error: `inline Cpp` declaration not at file scope [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━━━━━━━┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `inline Cpp` declaration not at file scope
|
||||
// CHECK:STDERR: · ┃ [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "";
|
||||
}
|
||||
|
||||
constraint N {
|
||||
// CHECK:STDERR: fail_nested.carbon:[[@LINE+2]]:3-16: error: `inline Cpp` declaration not at file scope [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━━━━━━━┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `inline Cpp` declaration not at file scope
|
||||
// CHECK:STDERR: · ┃ [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "";
|
||||
}
|
||||
|
||||
impl C as I {
|
||||
// CHECK:STDERR: fail_nested.carbon:[[@LINE+2]]:3-16: error: `inline Cpp` declaration not at file scope [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━━━━━━━┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: `inline Cpp` declaration not at file scope
|
||||
// CHECK:STDERR: · ┃ [InlineDeclNotAtFileScope]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "";
|
||||
}
|
||||
@@ -111,9 +152,18 @@ impl C as I {
|
||||
|
||||
fn F() {
|
||||
// TODO: Should this be a check error rather than a parse error?
|
||||
// CHECK:STDERR: fail_nested_fn.carbon:[[@LINE+4]]:3-8: error: expected expression [ExpectedExpr]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested_fn.carbon:[[@LINE+13]]:3
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━━━┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected expression [ExpectedExpr]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_nested_fn.carbon:[[@LINE+2]]:3-8: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested_fn.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ inline Cpp "";
|
||||
// CHECK:STDERR: · ━━━┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `handle invalid parse trees in `check``
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
inline Cpp "";
|
||||
}
|
||||
@@ -17,11 +17,28 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: This diagnostic isn't very good.
|
||||
import Cpp inline '''
|
||||
// CHECK:STDERR: fail_export_module_in_inline_cpp.carbon:[[@LINE+6]]:8-18: error: module declaration must not come from an #include directive [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_export_module_in_inline_cpp.carbon:[[@LINE+23]]:8
|
||||
// CHECK:STDERR: -> │ export module Foo;
|
||||
// CHECK:STDERR: · ━━┳━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must not come from an #include directive
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_export_module_in_inline_cpp.carbon:[[@LINE+4]]:8: error: module declaration must occur at the start of the translation unit [CppInteropParseError]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: add 'module;' to the start of the file to introduce a global module fragment [CppInteropParseNote]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: insert `module; ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╭─┤ fail_export_module_in_inline_cpp.carbon:[[@LINE+16]]:8
|
||||
// CHECK:STDERR: -> │ export module Foo;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must occur at the start of the translation
|
||||
// CHECK:STDERR: · ┃ unit
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: ├─┤ <carbon Cpp imports>
|
||||
// CHECK:STDERR: │ ;
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ add 'module;' to the start of the file to introduce a global module
|
||||
// CHECK:STDERR: · │ │ fragment
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ insert `module; ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
export module Foo;
|
||||
''';
|
||||
@@ -32,13 +49,35 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: This diagnostic isn't very good.
|
||||
import Cpp inline '''
|
||||
// CHECK:STDERR: fail_module_in_inline_cpp.carbon:[[@LINE+8]]:1-11: error: module declaration must not come from an #include directive [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_module_in_inline_cpp.carbon:[[@LINE+30]]:1
|
||||
// CHECK:STDERR: -> │ module Bar;
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must not come from an #include directive
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_module_in_inline_cpp.carbon:[[@LINE+6]]:1: error: module declaration must occur at the start of the translation unit [CppInteropParseError]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: add 'module;' to the start of the file to introduce a global module fragment [CppInteropParseNote]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: insert `module; ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╭─┤ fail_module_in_inline_cpp.carbon:[[@LINE+23]]:1
|
||||
// CHECK:STDERR: -> │ module Bar;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must occur at the start of the translation unit
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: ├─┤ <carbon Cpp imports>
|
||||
// CHECK:STDERR: │ ;
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ add 'module;' to the start of the file to introduce a global module
|
||||
// CHECK:STDERR: · │ │ fragment
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ insert `module; ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_module_in_inline_cpp.carbon:[[@LINE+2]]:8-10: error: module name 'Foo' specified on command line does not match name of module [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_module_in_inline_cpp.carbon:[[@LINE+8]]:8
|
||||
// CHECK:STDERR: -> │ module Bar;
|
||||
// CHECK:STDERR: · ┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: module name 'Foo' specified on command line does not match
|
||||
// CHECK:STDERR: · ┃ name of module
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
module Bar;
|
||||
''';
|
||||
@@ -49,21 +88,54 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: This diagnostic isn't very good.
|
||||
import Cpp inline '''
|
||||
// CHECK:STDERR: fail_global_module_in_inline_cpp.carbon:[[@LINE+4]]:1-7: error: module declaration must not come from an #include directive [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_global_module_in_inline_cpp.carbon:[[@LINE+15]]:1
|
||||
// CHECK:STDERR: -> │ module;
|
||||
// CHECK:STDERR: · ━━━┳━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must not come from an #include directive
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_global_module_in_inline_cpp.carbon:[[@LINE+2]]:1-7: error: 'module;' introducing a global module fragment can appear only at the start of the translation unit [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_global_module_in_inline_cpp.carbon:[[@LINE+8]]:1
|
||||
// CHECK:STDERR: -> │ module;
|
||||
// CHECK:STDERR: · ┳━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: 'module;' introducing a global module fragment can appear only at
|
||||
// CHECK:STDERR: · ┃ the start of the translation unit
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
module;
|
||||
|
||||
int n;
|
||||
|
||||
// CHECK:STDERR: fail_global_module_in_inline_cpp.carbon:[[@LINE+8]]:1-11: error: module declaration must not come from an #include directive [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_global_module_in_inline_cpp.carbon:[[@LINE+30]]:1
|
||||
// CHECK:STDERR: -> │ module Baz;
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must not come from an #include directive
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_global_module_in_inline_cpp.carbon:[[@LINE+6]]:1: error: module declaration must occur at the start of the translation unit [CppInteropParseError]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: add 'module;' to the start of the file to introduce a global module fragment [CppInteropParseNote]
|
||||
// CHECK:STDERR: <carbon Cpp imports>:1:1: note: insert `module; ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╭─┤ fail_global_module_in_inline_cpp.carbon:[[@LINE+23]]:1
|
||||
// CHECK:STDERR: -> │ module Baz;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: module declaration must occur at the start of the translation unit
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: ├─┤ <carbon Cpp imports>
|
||||
// CHECK:STDERR: │ ;
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ add 'module;' to the start of the file to introduce a global module
|
||||
// CHECK:STDERR: · │ │ fragment
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ insert `module; ` here [CppInteropFixItInsertion]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_global_module_in_inline_cpp.carbon:[[@LINE+2]]:8-10: error: module name 'Foo' specified on command line does not match name of module [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_global_module_in_inline_cpp.carbon:[[@LINE+8]]:8
|
||||
// CHECK:STDERR: -> │ module Baz;
|
||||
// CHECK:STDERR: · ┳━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: module name 'Foo' specified on command line does not match
|
||||
// CHECK:STDERR: · ┃ name of module
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
module Baz;
|
||||
''';
|
||||
@@ -74,7 +146,12 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: Also test that a valid module import works.
|
||||
import Cpp inline '''
|
||||
// CHECK:STDERR: fail_import_in_inline_cpp.carbon:[[@LINE+2]]:8-35: error: 'file_that_does_not_exist.h' file not found [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_import_in_inline_cpp.carbon:[[@LINE+7]]:8
|
||||
// CHECK:STDERR: -> │ import "file_that_does_not_exist.h";
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━┳━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: 'file_that_does_not_exist.h' file not found
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
import "file_that_does_not_exist.h";
|
||||
''';
|
||||
@@ -38,7 +38,12 @@ import Cpp;
|
||||
|
||||
fn CallLeakedA() -> i32 {
|
||||
// This should not be found as we have not imported "a.h".
|
||||
// CHECK:STDERR: fail_a_does_not_leak.carbon:[[@LINE+2]]:10-17: error: member name `GetA` not found in `Cpp` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: ╭─┤ fail_a_does_not_leak.carbon:[[@LINE+7]]:10
|
||||
// CHECK:STDERR: -> │ return Cpp.GetA();
|
||||
// CHECK:STDERR: · ━━━━┳━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: member name `GetA` not found in `Cpp`
|
||||
// CHECK:STDERR: · ┃ [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
return Cpp.GetA();
|
||||
}
|
||||
@@ -143,13 +148,30 @@ import Cpp;
|
||||
namespace N;
|
||||
|
||||
inline Cpp '''
|
||||
// CHECK:STDERR: fail_carbon_export_does_not_leak.carbon:[[@LINE+2]]:23: error: no type named 'ExportedClass' in namespace 'Carbon' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_carbon_export_does_not_leak.carbon:[[@LINE+8]]:23
|
||||
// CHECK:STDERR: -> │ using Leak1 = Carbon::ExportedClass;
|
||||
// CHECK:STDERR: · ───────╴╻
|
||||
// CHECK:STDERR: · ┗━━┫ error: no type named 'ExportedClass' in namespace
|
||||
// CHECK:STDERR: · ┃ 'Carbon'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
using Leak1 = Carbon::ExportedClass;
|
||||
// CHECK:STDERR: fail_carbon_export_does_not_leak.carbon:[[@LINE+2]]:26: error: no type named 'ExportedNested' in namespace 'Carbon::N' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_carbon_export_does_not_leak.carbon:[[@LINE+8]]:26
|
||||
// CHECK:STDERR: -> │ using Leak2 = Carbon::N::ExportedNested;
|
||||
// CHECK:STDERR: · ──────────╴╻
|
||||
// CHECK:STDERR: · ┗━━┫ error: no type named 'ExportedNested' in namespace
|
||||
// CHECK:STDERR: · ┃ 'Carbon::N'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
using Leak2 = Carbon::N::ExportedNested;
|
||||
// CHECK:STDERR: fail_carbon_export_does_not_leak.carbon:[[@LINE+2]]:23: error: no member named 'PkgA' in namespace 'Carbon' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_carbon_export_does_not_leak.carbon:[[@LINE+7]]:23
|
||||
// CHECK:STDERR: -> │ using Leak3 = Carbon::PkgA::SameName;
|
||||
// CHECK:STDERR: · ───────╴╻
|
||||
// CHECK:STDERR: · ┗━━┫ error: no member named 'PkgA' in namespace 'Carbon'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
using Leak3 = Carbon::PkgA::SameName;
|
||||
''';
|
||||
@@ -13,20 +13,29 @@
|
||||
// --- structured_binding.h
|
||||
|
||||
struct X { int a, b; };
|
||||
// CHECK:STDERR: ╷ ╭── included from: fail_todo_use_structured_binding.carbon [InCppInclude]
|
||||
// CHECK:STDERR: ├─┤ ./structured_binding.h:[[@LINE+12]]:7
|
||||
// CHECK:STDERR: -> │ auto [a, b] = X{};
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `Unsupported: Declaration type Binding`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: ├─┤ fail_todo_use_structured_binding.carbon
|
||||
// CHECK:STDERR: │ return Cpp.a;
|
||||
// CHECK:STDERR: · ──┬──
|
||||
// CHECK:STDERR: · ╰──┤ in `Cpp` name lookup for `a` [InCppNameLookup]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
auto [a, b] = X{};
|
||||
|
||||
// --- fail_todo_use_structured_binding.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: included from: fail_todo_use_structured_binding.carbon:[[@LINE+2]]:10 [InCppInclude]
|
||||
// CHECK:STDERR: ./structured_binding.h:3:7: error: semantics TODO: `Unsupported: Declaration type Binding` [SemanticsTodo]
|
||||
import Cpp library "structured_binding.h";
|
||||
|
||||
fn F() -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_use_structured_binding.carbon:[[@LINE+2]]:10-14: note: in `Cpp` name lookup for `a` [InCppNameLookup]
|
||||
// CHECK:STDERR:
|
||||
return Cpp.a;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
@@ -16,10 +16,18 @@
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp inline '''c++
|
||||
// CHECK:STDERR: unused.carbon:[[@LINE+2]]:12: warning: unused variable 'n' [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╭─┤ unused.carbon:[[@LINE+6]]:12
|
||||
// CHECK:STDERR: -> │ static int n = 0;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: unused variable 'n' [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
static int n = 0;
|
||||
// CHECK:STDERR: unused.carbon:[[@LINE+2]]:13: warning: unused function 'f' [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╭─┤ unused.carbon:[[@LINE+6]]:13
|
||||
// CHECK:STDERR: -> │ static void f() {}
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ warning: unused function 'f' [CppInteropParseWarning]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
static void f() {}
|
||||
''';
|
||||
|
||||
Reference in new issue
Block a user