]> git.ipfire.org Git - thirdparty/gcc.git/commit
avr: Fix wrong array bounds warning on SFR access
authorSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Mon, 19 Jun 2023 06:53:25 +0000 (12:23 +0530)
committerSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Mon, 19 Jun 2023 08:21:13 +0000 (13:51 +0530)
commit58e1bc2b1c8420773b16452d47932a6ca0d003fb
tree0994b2e3f8d41a5914b67d81a74acfe2555f2720
parentccfdda34341423c6034876856cd8ba50f0ca0ef3
avr: Fix wrong array bounds warning on SFR access

The warning was raised on accessing SFRs at addresses below the default
page size, as gcc considers accessing addresses in the first page of
memory as suspicious. This doesn't apply to an embedded target like the
avr, where both flash and RAM have zero as a valid address. Zero is also
a valid address in named address spaces (__memx, flash<n> etc..).

This commit implements TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID for the avr
target and reports to gcc that zero is a valid address on all
address spaces. It also disables flag_delete_null_pointer_checks
based on the target hook, and modifies target-supports.exp to add avr
to the list of targets that always keep null pointer checks. This fixes
a bunch of DejaGNU failures that occur otherwise.

PR target/105523

gcc/ChangeLog:

* common/config/avr/avr-common.cc: Remove setting
of OPT_fdelete_null_pointer_checks.
* config/avr/avr.cc (avr_option_override): Clear
flag_delete_null_pointer_checks if zero_address_valid.
(avr_addr_space_zero_address_valid): New function.
(TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): Provide target
hook.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_keeps_null_pointer_checks): Add
avr.
* gcc.target/avr/pr105523.c: New test.
gcc/common/config/avr/avr-common.cc
gcc/config/avr/avr.cc
gcc/testsuite/gcc.target/avr/pr105523.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp