Skip to content

Commit

Permalink
rust_debug: Cast size_t values to unsigned long before printing.
Browse files Browse the repository at this point in the history
Using %lu to format size_t values breaks 32 bit targets, and %zu is not
supported by one of the hosts GCC aims to support - HPUX

gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
	Cast size_t value to unsigned long.
	* expand/rust-proc-macro.cc (load_macros): Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
  • Loading branch information
CohenArthur committed Jan 18, 2024
1 parent 0cd26bd commit 5b40b9c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype,
}

const Resolver::PathProbeCandidate *selectedCandidate = nullptr;
rust_debug_loc (expr_locus, "resolved to %lu candidates", candidates.size ());
rust_debug_loc (expr_locus, "resolved to %lu candidates",
(unsigned long) candidates.size ());

// filter for the possible case of non fn type items
std::set<Resolver::PathProbeCandidate> filteredFunctionCandidates;
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/expand/rust-proc-macro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ load_macros (std::string path)
if (array == nullptr)
return {};

rust_debug ("Found %lu procedural macros", array->length);
rust_debug ("Found %lu procedural macros", (unsigned long) array->length);

return std::vector<ProcMacro::Procmacro> (array->macros,
array->macros + array->length);
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/typecheck/rust-hir-type-check-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,10 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)

auto candidate = *candidates.begin ();
rust_debug_loc (expr.get_method_name ().get_locus (),
"resolved method to: {%u} {%s} with [%zu] adjustments",
"resolved method to: {%u} {%s} with [%lu] adjustments",
candidate.candidate.ty->get_ref (),
candidate.candidate.ty->debug_str ().c_str (),
candidate.adjustments.size ());
(unsigned long) candidate.adjustments.size ());

// Get the adjusted self
Adjuster adj (receiver_tyty);
Expand Down

0 comments on commit 5b40b9c

Please sign in to comment.