On Sat, May 03, 2014 at 04:51:53PM +0530, Prathamesh Kulkarni wrote:
>   * c-tree.h (C_ARRAY_PARM): New macro, alias for DECL_LANG_FLAG_2.

"New macro." would be enough.

> --- gcc/c/c-decl.c    (revision 210004)
> +++ gcc/c/c-decl.c    (working copy)
> @@ -4650,6 +4650,8 @@ push_parm_decl (const struct c_parm *par
>    decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
>                        &attrs, expr, NULL, DEPRECATED_NORMAL);
>    decl_attributes (&decl, attrs, 0);
> +  

Trailing whitespace (you might want to drop this newline altogether).

> --- gcc/c/c-tree.h    (revision 210004)
> +++ gcc/c/c-tree.h    (working copy)
> @@ -66,6 +66,9 @@ along with GCC; see the file COPYING3.
>  /* For a FUNCTION_DECL, nonzero if it was an implicit declaration.  */
>  #define C_DECL_IMPLICIT(EXP) DECL_LANG_FLAG_2 (EXP)
>  
> +/* For a PARM_DECL, nonzero if parameter was declared as array */

"as an array.  */"

> --- gcc/c/c-typeck.c  (revision 210004)
> +++ gcc/c/c-typeck.c  (working copy)
> @@ -2732,6 +2732,13 @@ c_expr_sizeof_expr (location_t loc, stru
>    else
>      {
>        bool expr_const_operands = true;
> +
> +      if (warn_sizeof_array_argument && TREE_CODE (expr.value) == PARM_DECL 
> && C_ARRAY_PARM (expr.value)) 

Line too long.  Please move each condition on its own line.

> +     {
> +       warning_at (loc, 0, "sizeof on array parameter %qE shall return size 
> of %qT",

You want OPT_Wsizeof_array_argument instead of 0 here.
Also I'd s/shall/will/.  Also line is too long + trailing whitespace.

> +Wsizeof-array-argument
> +C Var(warn_sizeof_array_argument) Warning
> +Warn when sizeof is applied on a parameter declared as an array

I wonder if we want also ObjC here.  I guess it'd be good to have this
also for C++.

It seems that this could be enabled by default.

        Marek

Reply via email to