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/cp/cp-tree.h | |
| 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/cp/cp-tree.h')
| -rw-r--r-- | gcc/cp/cp-tree.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1e9e1af..4a5cb98 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -146,6 +146,7 @@ c-common.h, not after. DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL) USING_DECL_TYPENAME_P (in USING_DECL) DECL_VLA_CAPTURE_P (in FIELD_DECL) + DECL_ARRAY_PARAMETER_P (in PARM_DECL) 2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL). DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL) 3: DECL_IN_AGGR_P. @@ -3681,6 +3682,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define DECL_VLA_CAPTURE_P(NODE) \ DECL_LANG_FLAG_1 (FIELD_DECL_CHECK (NODE)) +/* Nonzero for PARM_DECL node means that this is an array function + parameter, i.e, a[] rather than *a. */ +#define DECL_ARRAY_PARAMETER_P(NODE) \ + DECL_LANG_FLAG_1 (PARM_DECL_CHECK (NODE)) + /* Nonzero for FIELD_DECL node means that this field is a base class of the parent object, as opposed to a member field. */ #define DECL_FIELD_IS_BASE(NODE) \ |
