Skip to content

Conversation

@bricknerb
Copy link
Contributor

This extends #6364 to allow having:

  • Cpp.unsigned_long as a distinct type when unsigned long is 32 bits.
  • Cpp.long_long and Cpp.unsigned_long_long as distinct types when long and unsigned long are 64 bits.

Similarly to #6364, we only support implicit conversions from the matching literal type (u32, i64 and u64).

See #6275 for rationale.

Part of #5263.

…ong64`

This extends carbon-language#6364 to allow having:
* `Cpp.unsigned_long` as a distinct type when `unsigned long` is 32 bits.
* `Cpp.long_long` and `Cpp.unsigned_long_long` as distinct types when `long` and `unsigned long` are 64 bits.

Similarly to carbon-language#6364, we only support implicit conversions from the matching literal type (`u32`, `i64` and `u64`).

See carbon-language#6275 for rationale.

Part of carbon-language#5263.
@bricknerb bricknerb marked this pull request as ready for review November 17, 2025 21:51
@bricknerb bricknerb requested a review from a team as a code owner November 17, 2025 21:51
@bricknerb bricknerb requested review from geoffromer and removed request for a team November 17, 2025 21:51
Copy link
Contributor

@geoffromer geoffromer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these types supported in lowering? If so, should there be tests for that?

}

// TODO: ImplicitAs from ULong32 to UInt(N) if N > 32.
final impl CppCompat.ULong32 as ImplicitAs(u32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: I think I'd find it a little clearer to group the conversions for the same type together (e.g. group this together with u32 as ImplicitAs(CppCompat.ULong32)), rather than grouping the conversions by whether they're to or from a CppCompat type.

unsigned int carbon_width,
llvm::StringRef cpp_compat_name)
-> TypeExpr {
if (cpp_width != carbon_width) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where you expect this to happen, and it's not a bug in the toolchain?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants