ada: New warning about noncomposing user-defined "="
authorBob Duff <duff@adacore.com>
Mon, 17 Oct 2022 15:56:27 +0000 (11:56 -0400)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 7 Nov 2022 08:36:35 +0000 (09:36 +0100)
commit2702882fdbd14ad647ea2a88c7f9ea2cd62fa23e
tree6f87bf0c0fb3ca2e3f67ad5d6c54f7fef7d6e2fc
parent9b07c1752b9bf49143a41c810e2db86f633fdb1c
ada: New warning about noncomposing user-defined "="

Print warning for a user-defined "=" that does not compose
as might be expected (i.e. is ignored for predefined "=" of
a containing record or array type). This warning is enabled by
-gnatw_q; we don't enable it by default because it generates
too many false positives. We also don't enable it via -gnatwa.

gcc/ada/

* exp_ch4.adb
(Expand_Array_Equality): Do not test Ltyp = Rtyp here, because
that is necessarily true. Move assertion thereof to more general
place.
(Expand_Composite_Equality): Pass in Outer_Type, for use in
warnings. Rename Typ to be Comp_Type, to more clearly distinguish
it from Outer_Type. Print warning when appropriate.
* exp_ch4.ads: Minor comment fix.
* errout.ads: There is no such pragma as Warning_As_Pragma --
Warning_As_Error must have been intended. Improve comment for ?x?.
* exp_ch3.adb
(Build_Untagged_Equality): Update comment to be accurate for more
recent versions of Ada.
* sem_case.adb
(Choice_Analysis): Declare user-defined "=" functions as abstract.
* sem_util.ads
(Is_Bounded_String): Give RM reference in comment.
* warnsw.ads, warnsw.adb
(Warn_On_Ignored_Equality): Implement new warning switch -gnatw_q.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Document new warning switch.
* gnat_ugn.texi: Regenerate.
gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
gcc/ada/errout.ads
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch4.ads
gcc/ada/gnat_ugn.texi
gcc/ada/sem_case.adb
gcc/ada/sem_util.ads
gcc/ada/warnsw.adb
gcc/ada/warnsw.ads