diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2024-12-03 14:19:40 +0100 |
---|---|---|
committer | Georg-Johann Lay <avr@gjlay.de> | 2024-12-03 21:52:06 +0100 |
commit | b6a43fe2c5498f823b5df735a4702f35a812e5bd (patch) | |
tree | 8a1b3ede7f40ca0abf0073da7a8763f7302c097c /gcc/config/avr | |
parent | 96f5fd3089075b56ea9ea85060213cc4edd7251a (diff) | |
download | gcc-b6a43fe2c5498f823b5df735a4702f35a812e5bd.zip gcc-b6a43fe2c5498f823b5df735a4702f35a812e5bd.tar.gz gcc-b6a43fe2c5498f823b5df735a4702f35a812e5bd.tar.bz2 |
AVR: Improve location of late diagnostics.
Some diagnostics are issues late, e.g. in avr_print_operand().
This patch uses the insn's location as a proxy for the operand
location. Without the patch, the location is usually input_location,
which points to the closing } of the function body.
gcc/
* config/avr/avr.cc (avr_insn_location): New variable.
(avr_final_prescan_insn): Set avr_insn_location.
(avr_asm_final_postscan_insn): Unset avr_insn_location after last insn.
(avr_print_operand): Pass avr_insn_location to warning_at.
gcc/testsuite/
* gcc.dg/Warray-bounds-33.c: Adjust for avr diagnostics.
* gcc.dg/pr56228.c: Same.
* gcc.dg/pr86124.c: Same.
* gcc.dg/pr94291.c: Same.
* gcc.dg/tree-ssa/pr82059.c: Same.
Diffstat (limited to 'gcc/config/avr')
-rw-r--r-- | gcc/config/avr/avr.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index ccf9b05..9bebd67 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -234,6 +234,7 @@ bool avr_has_rodata_p = false; insn condition for shift insn splitters. */ int n_avr_fuse_add_executed = 0; +static location_t avr_insn_location = UNKNOWN_LOCATION; /* Transform UP into lowercase and write the result to LO. @@ -2712,12 +2713,17 @@ avr_print_operand (FILE *file, rtx x, int code) fatal_insn ("bad address, not a constant:", addr); /* Assembler template with m-code is data - not progmem section */ if (text_segment_operand (addr, VOIDmode)) - if (warning (0, "accessing data memory with" - " program memory address")) - { - output_addr_const (stderr, addr); - fprintf(stderr,"\n"); - } + { + location_t loc = avr_insn_location != UNKNOWN_LOCATION + ? avr_insn_location + : input_location; + if (warning_at (loc, 0, "accessing data memory with" + " program memory address")) + { + output_addr_const (stderr, addr); + fprintf (stderr,"\n"); + } + } output_addr_const (file, addr); } else if (code == 'o') @@ -2760,12 +2766,17 @@ avr_print_operand (FILE *file, rtx x, int code) { /* Constant progmem address - like used in jmp or call */ if (text_segment_operand (x, VOIDmode) == 0) - if (warning (0, "accessing program memory" - " with data memory address")) - { - output_addr_const (stderr, x); - fprintf (stderr, "\n"); - } + { + location_t loc = avr_insn_location != UNKNOWN_LOCATION + ? avr_insn_location + : input_location; + if (warning_at (loc, 0, "accessing program memory" + " with data memory address")) + { + output_addr_const (stderr, x); + fprintf (stderr, "\n"); + } + } /* Use normal symbol for direct address no linker trampoline needed */ output_addr_const (file, x); } @@ -2954,6 +2965,8 @@ void avr_final_prescan_insn (rtx_insn *insn, rtx * /*operands*/, int /*num_operands*/) { + avr_insn_location = LOCATION_LOCUS (INSN_LOCATION (insn)); + if (avr_log.rtx_costs) { rtx set = single_set (insn); @@ -2982,6 +2995,9 @@ avr_final_prescan_insn (rtx_insn *insn, rtx * /*operands*/, static void avr_asm_final_postscan_insn (FILE *stream, rtx_insn *insn, rtx *, int) { + if (!next_real_insn (insn)) + avr_insn_location = UNKNOWN_LOCATION; + if (cfun->machine->gasisr.yes && !next_real_insn (insn)) { |