mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:41:06 +01:00
Support import of typedefs. (#5787)
Unify code paths for importing classes by name and importing them indirectly when their type is referenced. Switch to using the general type import machinery to import all type declarations, which allows typedef declarations naming importable types to be used too. Fix up handling of error cases to consistently only produce an Error InstId after actually producing an error message, so that we can produce exactly one diagnostic in failure cases. Remove TODO error for unions that previously was only produced when importing them indirectly, not when importing them by name. Import of unions is exactly as complete / incomplete as import of other class types, so treating them differently doesn't seem necessary.
This commit is contained in:
+6
-10
@@ -38,16 +38,12 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "stddef.h";
|
||||
|
||||
// TODO: Once we can import typedefs, this should work.
|
||||
// CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+11]]:8: error: semantics TODO: `Unsupported: Declaration type Typedef` [SemanticsTodo]
|
||||
// CHECK:STDERR: var n: Cpp.size_t;
|
||||
// TODO: Once we can import `unsigned long` / `unsigned long long`, this should work.
|
||||
// CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+7]]:8: error: semantics TODO: `Unsupported: Type declaration: size_t` [SemanticsTodo]
|
||||
// CHECK:STDERR: var n: Cpp.size_t = 42;
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+8]]:8: note: in `Cpp` name lookup for `size_t` [InCppNameLookup]
|
||||
// CHECK:STDERR: var n: Cpp.size_t;
|
||||
// CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+4]]:8: note: in `Cpp` name lookup for `size_t` [InCppNameLookup]
|
||||
// CHECK:STDERR: var n: Cpp.size_t = 42;
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_stddef_directly.carbon:[[@LINE+4]]:8: error: member name `size_t` not found in `Cpp` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: var n: Cpp.size_t;
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
var n: Cpp.size_t;
|
||||
var n: Cpp.size_t = 42;
|
||||
|
||||
Reference in New Issue
Block a user