diff options
author | Marek Polacek <polacek@redhat.com> | 2014-07-06 19:00:10 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-07-06 19:00:10 +0000 |
commit | 773ec47fe60d07116c11f2eda13ef3cf25fae65a (patch) | |
tree | dbe62f51aeeeb3f4e0e71eea55e603f187e0fdbf /gcc/c-family | |
parent | dc044bfb723e7c720b9111f0369d1c9165abff70 (diff) | |
download | gcc-773ec47fe60d07116c11f2eda13ef3cf25fae65a.zip gcc-773ec47fe60d07116c11f2eda13ef3cf25fae65a.tar.gz gcc-773ec47fe60d07116c11f2eda13ef3cf25fae65a.tar.bz2 |
re PR c/6940 (taking sizeof array parameter should trigger a warning)
PR c/6940
* doc/invoke.texi: Document -Wsizeof-array-argument.
c-family/
* c.opt (Wsizeof-array-argument): New option.
c/
* c-decl.c (grokdeclarator): Set C_ARRAY_PARAMETER.
* c-tree.h (C_ARRAY_PARAMETER): Define.
* c-typeck.c (c_expr_sizeof_expr): Warn when using sizeof on an array
function parameter.
cp/
* cp-tree.h (DECL_ARRAY_PARAMETER_P): Define.
* decl.c (grokdeclarator): Set DECL_ARRAY_PARAMETER_P.
* typeck.c (cxx_sizeof_expr): Warn when using sizeof on an array
function parameter.
testsuite/
* c-c++-common/Wsizeof-pointer-memaccess1.c: Use
-Wno-sizeof-array-argument.
* c-c++-common/Wsizeof-pointer-memaccess2.c: Likewise.
* g++.dg/warn/Wsizeof-pointer-memaccess-1.C: Likewise.
* gcc.dg/Wsizeof-pointer-memaccess1.c: Likewise.
* g++.dg/torture/Wsizeof-pointer-memaccess1.C: Likewise.
* g++.dg/torture/Wsizeof-pointer-memaccess2.C: Likewise.
* gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Likewise.
* c-c++-common/sizeof-array-argument.c: New test.
* gcc.dg/vla-5.c: Add dg-warnings.
../libgomp/ * testsuite/libgomp.c/appendix-a/a.29.1.c (f): Add dg-warnings.
From-SVN: r212312
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d667ed8..5bd9c1e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2014-07-06 Marek Polacek <polacek@redhat.com> + + PR c/6940 + * c.opt (Wsizeof-array-argument): New option. + 2014-07-03 Jakub Jelinek <jakub@redhat.com> * c-ada-spec.c (dump_ada_nodes): Don't call qsort if diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index c89040a..faef774 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -534,6 +534,10 @@ Wsizeof-pointer-memaccess C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) Warn about suspicious length parameters to certain string functions if the argument uses sizeof +Wsizeof-array-argument +C ObjC C++ ObjC++ Var(warn_sizeof_array_argument) Warning Init(1) +Warn when sizeof is applied on a parameter declared as an array + Wsuggest-attribute=format C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning Warn about functions which might be candidates for format attributes |