Remove duplicate check for exporting a specific class (#7541)

The check for a specific in `TryMapClassType` is unnecessary;
immediately after it calls `ExportClassToCpp`, which has the same check.
The latter also has a `context.TODO`, which provides a clearer error.

Also improved the `LocId` in `ExportClassToCpp` to use the location of
the first decl rather than the empty location of the class type. This is
the same fix as
https://github.com/carbon-language/carbon-lang/pull/7533, just applied a
little more broadly. This makes the `context.TODO` above point at the
class rather than the start of the source file.
This commit is contained in:
Nicholas Bishop
2026-07-21 18:35:20 +00:00
committed by GitHub
parent d234de41e7
commit 2e61685658
6 changed files with 27 additions and 22 deletions
@@ -90,6 +90,10 @@ void G() {
library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+4]]:1: error: semantics TODO: `interop with specific class` [SemanticsTodo]
// CHECK:STDERR: class A(T: type) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
class A(T: type) {
fn F[U: type](x: T, y: U);
}
@@ -105,7 +109,7 @@ void f() {
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+4]]:11: error: no type named 'B' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 22 | Carbon::B b;
// CHECK:STDERR: 26 | Carbon::B b;
// CHECK:STDERR: | ~~~~~~~~^
// CHECK:STDERR:
Carbon::B b;