[Ada] Warn on 'in out' param containing access in predefined private type

Pierre-Marie de Rodat derodat@adacore.com
Thu Jun 17 14:33:11 GMT 2021


Normally the warnings:

    warning: formal parameter "..." is not modified
    warning: mode could be "in" instead of "in out"

are disabled if the type contains components of an access type.  This
patch enables such warnings if the only such components are in internal
private types.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_util.adb, sem_util.ads (Has_Access_Values): New formal
	Include_Internal to indicate whether internal types should be
	included.
	* sem_warn.adb (Check_References): Change E_Out_Parameter to
	Formal_Kind, to match the comment about Spec_Entity.  Pass
	Include_Internal => False to Has_Access_Values, so that we warn
	on types with access values that happen to be in internal types,
	such as Unbounded_String.
	* sem_attr.adb (Attribute_Has_Access_Values): Pass
	Include_Internal => True to Has_Access_Values, to preserve
	existing behavior.
	* libgnat/g-rewdat.adb (Do_Output): Change B from 'in out' to
	'in', to avoid warning enabled by the change to sem_warn.adb.
	* libgnat/s-objrea.adb (Check_Read_Offset): Change S from 'in
	out' to 'in', to avoid warning enabled by the change to
	sem_warn.adb.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 6740 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210617/f4c46d7e/attachment-0001.bin>


More information about the Gcc-patches mailing list