aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/doc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2022-10-17 11:56:27 -0400
committerMarc Poulhiès <poulhies@adacore.com>2022-11-07 09:36:35 +0100
commit2702882fdbd14ad647ea2a88c7f9ea2cd62fa23e (patch)
tree6f87bf0c0fb3ca2e3f67ad5d6c54f7fef7d6e2fc /gcc/ada/doc
parent9b07c1752b9bf49143a41c810e2db86f633fdb1c (diff)
downloadgcc-2702882fdbd14ad647ea2a88c7f9ea2cd62fa23e.zip
gcc-2702882fdbd14ad647ea2a88c7f9ea2cd62fa23e.tar.gz
gcc-2702882fdbd14ad647ea2a88c7f9ea2cd62fa23e.tar.bz2
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.
Diffstat (limited to 'gcc/ada/doc')
-rw-r--r--gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
index 83bc50f..31e2e31 100644
--- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
+++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
@@ -2795,6 +2795,8 @@ of the pragma in the :title:`GNAT_Reference_manual`).
* :switch:`-gnatw.q` (questionable layout of record types)
+ * :switch:`-gnatw_q` (ignored equality)
+
* :switch:`-gnatw_r` (out-of-order record representation clauses)
* :switch:`-gnatw.s` (overridden size clause)
@@ -3687,6 +3689,25 @@ of the pragma in the :title:`GNAT_Reference_manual`).
a record type would very likely cause inefficiencies.
+.. index:: -gnatw_q (gcc)
+
+:switch:`-gnatw_q`
+ *Activate warnings for ignored equality operators.*
+
+ This switch activates warnings for a user-defined "=" function that does
+ not compose (i.e. is ignored for a predefined "=" for a composite type
+ containing a component whose type has the user-defined "=" as
+ primitive). Note that the user-defined "=" must be a primitive operator
+ in order to trigger the warning.
+
+ The default is that these warnings are not given.
+
+.. index:: -gnatw_Q (gcc)
+
+:switch:`-gnatw_Q`
+ *Suppress warnings for ignored equality operators.*
+
+
.. index:: -gnatwr (gcc)
:switch:`-gnatwr`