https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89350

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Well, we could perhaps do something like:
--- gcc/gimple-ssa-evrp.c.jj    2019-01-01 12:37:15.712998659 +0100
+++ gcc/gimple-ssa-evrp.c       2019-02-15 09:27:49.569441402 +0100
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.
 #include "tree-cfgcleanup.h"
 #include "vr-values.h"
 #include "gimple-ssa-evrp-analyze.h"
+#include "tree-dfa.h"

 class evrp_folder : public substitute_and_fold_engine
 {
@@ -307,6 +308,21 @@ execute_early_vrp ()
   scev_initialize ();
   calculate_dominance_info (CDI_DOMINATORS);

+  /* argc in main is never negative.  */
+  if (MAIN_NAME_P (DECL_NAME (current_function_decl))
+      && DECL_ARGUMENTS (current_function_decl))
+    {
+      tree argc = DECL_ARGUMENTS (current_function_decl);
+      if (TYPE_MAIN_VARIANT (TREE_TYPE (argc)) == integer_type_node)
+       {
+         argc = ssa_default_def (cfun, argc);
+         if (argc && SSA_NAME_RANGE_INFO (argc) == NULL)
+           set_range_info (argc, VR_RANGE,
+                           wi::zero (TYPE_PRECISION (integer_type_node)),
+                           wi::to_wide (TYPE_MAX_VALUE (integer_type_node)));
+       }
+    }
+
   /* Walk stmts in dominance order and propagate VRP.  */
   evrp_dom_walker walker;
   walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
(not really sure if it will work fine with Ada, it does some games with main).

That said, I bet the original package code didn't have the warning in main but
somewhere else.

Reply via email to