2013/3/11 Georg-Johann Lay <a...@gjlay.de>: > This patch implements a new warning option -Waddr-space-convert warns about > conversions to a non-containing address space. > > Address spaces are implemented in such a way that each address space is > contained in each other space so that casting is possible, e.g. in code like > > char read_c (bool in_flash, const char *str) > { > if (in_flash) > return * (const __flash char*) str; > else > return *str; > } > > However, there are no warning about implicit or explicit address space > conversions, which makes it hard to port progmem code to address space code. > > If an address space qualifier is missing, e.g. when calling a function that is > not qualified correctly, this would result in wrong code (in contrast to > pgm_read that work no matter how the address is qualified). > > There is still some work to do to get more precise warnings and this is just a > first take to implement PR56263, see the FIXME in the source. > > The details can be worked out later, e.g. for 4.8.1. > > > Ok for trunk? > > > PR target/56263 > * config/avr/avr.c (TARGET_CONVERT_TO_TYPE): Define to... > (avr_convert_to_type): ...this new static function. > * config/avr/avr.opt (-Waddr-space-convert): New C option. > * doc/invoke.texi (AVR Options): Document it.
Approved. Denis.