This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add warning about false being implicitly converted to NULL in parameter passing


Dirk Mueller <dmueller@suse.de> writes:

| Hi, 
| 
| Patch below was bootstrapped and regtested on i686-suse-linux.
| 
| 
| 2007-03-11  Dirk Mueller  <dmueller@suse.de>
| 
|         PR c++/30860
|         * call.c (convert_like_real): Add conversion warning
|         about false being converted to NULL in argument passing.

This area is growing in warning issuance, and that function starts
competing with other monsters.  Please factor the
junk inside the if (issue_conversion_warnings)

  if (issue_conversion_warnings)
    {
      tree t = non_reference (totype);

      /* Issue warnings about peculiar, but valid, uses of NULL.  */
      if (expr == null_node && TREE_CODE (t) != BOOLEAN_TYPE && ARITHMETIC_TYPE\
_P (t))
        {
          if (fn)
            warning (OPT_Wconversion, "passing NULL to non-pointer argument %P \
of %qD",
                     argnum, fn);
          else
            warning (OPT_Wconversion, "converting to non-pointer type %qT from \
NULL", t);
        }

      /* Warn about assigning a floating-point type to an integer type.  */
      if (TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
          && TREE_CODE (t) == INTEGER_TYPE)
        {
          if (fn)
            warning (OPT_Wconversion, "passing %qT for argument %P to %qD",
                     TREE_TYPE (expr), argnum, fn);
          else
            warning (OPT_Wconversion, "converting to %qT from %qT", t, TREE_TYP\
E (expr));
        }
    }

where you add your new warning, into a separate function.  
Patch approved with that change.

Thanks,

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]