Skip to content

Commit 9482951

Browse files
powerboat9P-E-P
authored andcommitted
gccrs: Add rust_debug_fmt
This should allow the use of gcc diagnostic format specifiers in debug diagnostics, in exchange for stricter diagnostic quality checks. gcc/rust/ChangeLog: * rust-diagnostics.cc (rust_debug_fmt_at): New function definition. * rust-diagnostics.h (rust_debug_fmt): New function-like macro definition. (rust_debug_fmt_at): New function declaration. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
1 parent fde042e commit 9482951

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

gcc/rust/rust-diagnostics.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,19 @@ rust_debug_loc (const location_t location, const char *fmt, ...)
420420
rust_be_inform (location, rval);
421421
}
422422

423+
void
424+
rust_debug_fmt_at (const location_t location, const char *fmt, ...)
425+
{
426+
if (!rust_be_debug_p ())
427+
return;
428+
429+
va_list ap;
430+
431+
va_start (ap, fmt);
432+
rust_be_inform (location, expand_message (fmt, ap));
433+
va_end (ap);
434+
}
435+
423436
namespace Rust {
424437

425438
/**

gcc/rust/rust-diagnostics.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,10 @@ struct Error
307307
void rust_debug_loc (const location_t location, const char *fmt,
308308
...) ATTRIBUTE_PRINTF_2;
309309

310+
// like rust_debug, but has gcc diagnostic formatting
311+
#define rust_debug_fmt(...) rust_debug_fmt_at (UNDEF_LOCATION, __VA_ARGS__)
312+
313+
void rust_debug_fmt_at (location_t location, const char *fmt, ...)
314+
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
315+
310316
#endif // !defined(RUST_DIAGNOSTICS_H)

0 commit comments

Comments
 (0)