-
Notifications
You must be signed in to change notification settings - Fork 293
[DNM] Fix wide-string override_ty
#1645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f85ace1
65c0865
6e15fbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3778,10 +3778,41 @@ impl<'c> Translation<'c> { | |
| return self.convert_expr(ctx, expr, override_ty); | ||
| } | ||
| } | ||
| if kind == CastKind::ArrayToPointerDecay && override_ty.is_some() { | ||
| let target_elem = match &self | ||
| .ast_context | ||
| .resolve_type(override_ty.unwrap().ctype) | ||
| .kind | ||
| { | ||
| CTypeKind::Pointer(qtype) => qtype.ctype, | ||
| k => panic!("ArrayToPointerDecay producing non-pointer type {k:?}"), | ||
| }; | ||
| let new_array_override_ty_kind = | ||
| match &self.ast_context.resolve_type(source_ty.ctype).kind { | ||
| CTypeKind::ConstantArray(_elem, len) => { | ||
| CTypeKind::ConstantArray(target_elem, *len) | ||
| } | ||
| CTypeKind::VariableArray(_elem, len) => { | ||
| CTypeKind::VariableArray(target_elem, *len) | ||
| } | ||
| k => panic!("ArrayToPointerDecay on non-array type {k:?}"), | ||
| }; | ||
| // | ||
| // && Some(source_ty.ctype) != override_ty.map(|x| x.ctype) | ||
| let new_array_override_ty = self | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than trying to synthesize a completely new array type here, could |
||
| .ast_context | ||
| .type_for_kind(&new_array_override_ty_kind) | ||
| .expect(&format!( | ||
| "type id did not already exist for {:?}", | ||
| new_array_override_ty_kind | ||
| )); | ||
|
|
||
| self.convert_expr(ctx, expr, Some(CQualTypeId::new(new_array_override_ty)))? | ||
| } | ||
| // LValueToRValue casts don't actually change the type, so it still makes sense | ||
| // to translate their inner expression with the expected type from outside the | ||
| // cast. | ||
| if kind == CastKind::LValueToRValue | ||
| else if kind == CastKind::LValueToRValue | ||
| && Some(source_ty.ctype) != override_ty.map(|x| x.ctype) | ||
| { | ||
| self.convert_expr(ctx, expr, override_ty)? | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't actually return
Noneanymore, that I can see?