Improve source location in an import error. (#5887)

When attempting to import a definition of a class with virtual bases,
diagnose the point of use instead of the point of definition of the
class.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
Richard Smith
2025-07-31 00:45:38 +00:00
committed by GitHub
co-authored by Chandler Carruth
parent 7f96069b95
commit b320ea77ec
2 changed files with 16 additions and 11 deletions
+3 -2
View File
@@ -175,11 +175,12 @@ fn Convert(p: Cpp.B*) {
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_todo_use_virtual_inheritance.carbon:[[@LINE+2]]:1: in import [InImport]
// CHECK:STDERR: ./virtual_inheritance.h:3: error: semantics TODO: `class with virtual bases` [SemanticsTodo]
import Cpp library "virtual_inheritance.h";
fn Convert(p: Cpp.B*) -> Cpp.A* {
// CHECK:STDERR: fail_todo_use_virtual_inheritance.carbon:[[@LINE+14]]:3: error: semantics TODO: `class with virtual bases` [SemanticsTodo]
// CHECK:STDERR: return p;
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: fail_todo_use_virtual_inheritance.carbon:[[@LINE+11]]:3: note: while completing C++ class type `Cpp.B` [InCppTypeCompletion]
// CHECK:STDERR: return p;
// CHECK:STDERR: ^~~~~~~~~