mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 04:00:28 +00:00
Support for passing pointers to function templates. (#6080)
When a function template takes a parameter of deduced type, and we deduce that type to a pointer type because we passed a Carbon pointer as the argument, don't complain that the deduced type is not nullable. We still know that it can't be null, because we deduced it from a non-nullable type.
This commit is contained in:
1 parent
b054e3d2b0
commit
9d84391f11
2 files changed
+228
-2
No files matched your search
@@ -1255,8 +1255,12 @@ static auto MapPointerType(Context& context, clang::QualType type,
|
||||
if (auto nullability = type->getNullability();
|
||||
!nullability.has_value() ||
|
||||
*nullability != clang::NullabilityKind::NonNull) {
|
||||
// TODO: Support nullable pointers.
|
||||
return TypeExpr::None;
|
||||
// If the type was produced by C++ template substitution, then we assume it
|
||||
// was deduced from a Carbon pointer type, so it's non-null.
|
||||
if (!type->getAs<clang::SubstTemplateTypeParmType>()) {
|
||||
// TODO: Support nullable pointers.
|
||||
return TypeExpr::None;
|
||||
}
|
||||
}
|
||||
|
||||
SemIR::TypeId pointer_type_id =
|
||||
|
||||
Reference in new issue
Block a user