aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/doc/gnat_ugn
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2022-12-15 16:50:05 -0800
committerMarc Poulhiès <poulhies@adacore.com>2023-05-15 11:36:42 +0200
commita3594ab9646e083eb0e5984907285f6f2162eeea (patch)
tree2e17aeb06f6cfc5a13933dd56a1a59f2f5349316 /gcc/ada/doc/gnat_ugn
parenta1f35b49196ca219863cc6e64eb1d1eb1483cca9 (diff)
downloadgcc-a3594ab9646e083eb0e5984907285f6f2162eeea.zip
gcc-a3594ab9646e083eb0e5984907285f6f2162eeea.tar.gz
gcc-a3594ab9646e083eb0e5984907285f6f2162eeea.tar.bz2
ada: Emit warnings for (some) ineffective static predicate tests
Generate a warning if a static predicate tests for a value that does not belong to the parent subtype. For example, in subtype S is Positive with Static_Predicate => S not in 0 | 11 | 222; the 0 is ineffective because Positive already excludes that value. Generation of this new warning is controlled by the -gnatw_s switch, which can also be enabled via -gnatwa. gcc/ada/ * warnsw.ads: Add a new element, Warn_On_Ineffective_Predicate_Test, to the Opt_Warnings_Enum enumeration type. * warnsw.adb: Bind "-gnatw_s" to the new Warn_On_Ineffective_Predicate_Test switch. Add the new switch to the set of switches enabled by -gnata . * sem_ch13.adb (Build_Discrete_Static_Predicate): Declare new local procedure, Warn_If_Test_Ineffective, which conditionally generates new warning. Call this new procedure when building a new element of an RList. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Document the -gnatw_s switch (and the corresponding -gnatw_S switch). * gnat_ugn.texi: Regenerate.
Diffstat (limited to 'gcc/ada/doc/gnat_ugn')
-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 634bbc9..79da3c2 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
@@ -2801,6 +2801,8 @@ of the pragma in the :title:`GNAT_Reference_manual`).
* :switch:`-gnatw.s` (overridden size clause)
+ * :switch:`-gnatw_s` (ineffective predicate test)
+
* :switch:`-gnatwt` (tracking of deleted conditional code)
* :switch:`-gnatw.u` (unordered enumeration)
@@ -3834,6 +3836,25 @@ of the pragma in the :title:`GNAT_Reference_manual`).
warnings when an array component size overrides a size clause.
+.. index:: -gnatw_s (gcc)
+.. index:: Warnings
+
+:switch:`-gnatw_s`
+ *Activate warnings on ineffective predicate tests.*
+
+ This switch activates warnings on Static_Predicate aspect
+ specifications that test for values that do not belong to
+ the parent subtype. Not all such ineffective tests are detected.
+
+.. index:: -gnatw_S (gcc)
+
+:switch:`-gnatw_S`
+ *Suppress warnings on ineffective predicate tests.*
+
+ This switch suppresses warnings on Static_Predicate aspect
+ specifications that test for values that do not belong to
+ the parent subtype.
+
.. index:: -gnatwt (gcc)
.. index:: Deactivated code, warnings
.. index:: Deleted code, warnings