translate-c: Prevent mistranslation of fp literals
When trying to retrieve 80bit fp values from clang using getValueAsApproximateDouble we'd eventually hit the ceiling value and return infinity, an invalid value for a fp literal. Add some logic to prevent this error and warn the user. Closes #8602
This commit is contained in:
@@ -2528,6 +2528,11 @@ double ZigClangFloatingLiteral_getValueAsApproximateDouble(const ZigClangFloatin
|
||||
return casted->getValueAsApproximateDouble();
|
||||
}
|
||||
|
||||
ZigClangAPFloatBase_Semantics ZigClangFloatingLiteral_getRawSemantics(const ZigClangFloatingLiteral *self) {
|
||||
auto casted = reinterpret_cast<const clang::FloatingLiteral *>(self);
|
||||
return static_cast<ZigClangAPFloatBase_Semantics>(casted->getRawSemantics());
|
||||
}
|
||||
|
||||
enum ZigClangStringLiteral_StringKind ZigClangStringLiteral_getKind(const struct ZigClangStringLiteral *self) {
|
||||
auto casted = reinterpret_cast<const clang::StringLiteral *>(self);
|
||||
return (ZigClangStringLiteral_StringKind)casted->getKind();
|
||||
|
||||
Reference in New Issue
Block a user