[Ada] Fix bugs with volatile and components of aggregate types

Eric Botcazou ebotcazou@adacore.com
Sat Jun 18 13:01:00 GMT 2011


This is the usual problem of volatile accesses not preserved under (heavy) 
optimization.  In Ada, we can put pragma Volatile on components of composite 
types without putting it on the enclosing type itself, but this doesn't really 
work when you're starting to optimize.

Mostly gigi changes, but this plugs a hole in type_internals_preclude_sra_p 
which already tests TREE_THIS_VOLATILE on fields of record and union types but 
doesn't perform the equivalent test for array types.

Tested on i586-suse-linux, applied on mainline, as obvious for the SRA bits.


2011-06-18  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-sra.c (type_internals_preclude_sra_p) <ARRAY_TYPE>: Return true
	if the element type is volatile.
ada/
	* gcc-interface/decl.c (gnat_to_gnu_component_type): Use GNAT_TYPE
	local variable throughout.  Remove useless call to Base_Type.
	(gnat_to_gnu_field): Use GNAT_FIELD_TYPE local variable throughout.
	Take it also into account for the volatileness of the field.  Set the
	TREE_SIDE_EFFECTS flag as well in this case.  Reorder some warnings.


2011-06-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/volatile6.adb: New test.
	* gnat.dg/volatile7.adb: Likewise.
	* gnat.dg/volatile8.adb: Likewise.
	* gnat.dg/volatile9.adb: Likewise.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 6433 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110618/6e9f1c9c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile6.adb
Type: text/x-adasrc
Size: 368 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110618/6e9f1c9c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile7.adb
Type: text/x-adasrc
Size: 430 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110618/6e9f1c9c/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile8.adb
Type: text/x-adasrc
Size: 429 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110618/6e9f1c9c/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile9.adb
Type: text/x-adasrc
Size: 403 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110618/6e9f1c9c/attachment-0004.bin>


More information about the Gcc-patches mailing list