mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Allow conversion between T* and Cpp.void*. (#6575)
Support an implicit conversion from `T*` to `Cpp.void*` and to `const Cpp.void*`, and an `unsafe as` conversion in the opposite direction. In order to support C++ calls taking and returning `void*` (which get mapped to Carbon `Optional(Cpp.void*)`, also support conversions from `Optional(T)` to `Optional(U)` if there's a conversion from `T` to `U`. Fix a bug in `OptionalStorage` for `T*` where its `HasValue` was exactly backwards.
This commit is contained in:
@@ -719,6 +719,13 @@ constexpr BuiltinInfo PointerIsNull = {
|
||||
"pointer.is_null",
|
||||
ValidateSignature<auto(MaybeUnformed<PointerTo<AnyType>>)->Bool>};
|
||||
|
||||
// "pointer.unsafe_convert": convert a pointer of one type to a pointer of a
|
||||
// different type without performing any checking that the conversion makes
|
||||
// sense.
|
||||
constexpr BuiltinInfo PointerUnsafeConvert = {
|
||||
"pointer.unsafe_convert",
|
||||
ValidateSignature<auto(PointerTo<AnyType>)->PointerTo<AnyType>>};
|
||||
|
||||
// "type.and": facet type combination.
|
||||
constexpr BuiltinInfo TypeAnd = {"type.and",
|
||||
ValidateSignature<auto(Type, Type)->Type>};
|
||||
|
||||
Reference in New Issue
Block a user