mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Support for float <-> float conversions. (#7279)
Implement support for floating-point <-> floating-point type conversions as described in https://github.com/carbon-language/carbon-lang/pull/820 and https://github.com/carbon-language/carbon-lang/pull/845. Value-preserving conversions are implicit; narrowing conversions require explicit `as`. Assisted-by: Gemini via Antigravity
This commit is contained in:
@@ -702,6 +702,10 @@ constexpr BuiltinInfo FloatDivAssign = {
|
||||
"float.div_assign",
|
||||
ValidateSignature<auto(ByRef<SizedFloatT>, SizedFloatT)->NoReturn>};
|
||||
|
||||
// Converts between floating-point types, without checking.
|
||||
constexpr BuiltinInfo FloatConvert = {"float.convert",
|
||||
ValidateSignature<auto(FloatT)->FloatU>};
|
||||
|
||||
// Converts between floating-point types, with a diagnostic if the value doesn't
|
||||
// fit.
|
||||
constexpr BuiltinInfo FloatConvertChecked = {
|
||||
@@ -859,6 +863,7 @@ auto BuiltinFunctionKind::IsCompTimeOnly(const File& sem_ir,
|
||||
// Checked conversions are compile-time only.
|
||||
return true;
|
||||
|
||||
case FloatConvert:
|
||||
case FloatConvertInt:
|
||||
case IntConvert:
|
||||
case IntConvertChar:
|
||||
|
||||
Reference in New Issue
Block a user