[Patch,AVR]: Fix PR56263

Georg-Johann Lay avr@gjlay.de
Mon Mar 11 18:03:00 GMT 2013


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: addrspace-convert.diff
Type: text/x-patch
Size: 3426 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130311/b53e368e/attachment.bin>


More information about the Gcc-patches mailing list