aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2016-11-13 19:38:36 +0000
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>2016-11-13 19:38:36 +0000
commit975672f3573329b6ef9f687b706c566944a5887f (patch)
tree9aad4b4532ab8376d649d4e85993c1dd06279056 /gcc/cp
parent8d5a1b4f64ed7e4c3712ec1a27c59441e89e5ea9 (diff)
downloadgcc-975672f3573329b6ef9f687b706c566944a5887f.zip
gcc-975672f3573329b6ef9f687b706c566944a5887f.tar.gz
gcc-975672f3573329b6ef9f687b706c566944a5887f.tar.bz2
re PR tree-optimization/35503 (Warning about restricted pointers?)
2016-11-13 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR c/35503 * doc/invoke.texi: Document Wrestrict. * pretty-print.c (pp_format): Add case for "Z" specifier. (test_pp_format): Test "Z" specifier. c-family/ * c-common.h (warn_for_restrict): Declare. * c-warn.c: Include gcc-rich-location.h. (warn_for_restrict): New function. * c-format.c (gcc_tdiag_char_table): Add entry for "Z" specifier. (gcc_cdiag_char_table): Likewise. (gcc_cxxdiag_char_table): Likewise. * c.opt (Wrestrict): New option. c/ * c-parser.c (c_parser_postfix_expression_after_primary): Call warn_for_restrict. cp/ * parser.c (cp_parser_postfix_pexpression): Call warn_for_restrict. testsuite/ * c-c++-common/pr35503-1.c: New test. * c-c++-common/pr35503-2.c: Likewise. * c-c++-common/pr35503-3.c: Likewise. * gcc.dg/format/gcc_diag-1.c: Add tests for "Z" specifier. From-SVN: r242366
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/parser.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b3b69b3..1efe4ea 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6925,6 +6925,29 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
warn_for_memset (input_location, arg0, arg2, literal_mask);
}
+ if (TREE_CODE (postfix_expression) == FUNCTION_DECL
+ && warn_restrict)
+ {
+ unsigned i;
+ tree arg;
+ FOR_EACH_VEC_SAFE_ELT (args, i, arg)
+ TREE_VISITED (arg) = 0;
+
+ unsigned param_pos = 0;
+ for (tree decl = DECL_ARGUMENTS (postfix_expression);
+ decl != NULL_TREE;
+ decl = DECL_CHAIN (decl), param_pos++)
+ {
+ tree type = TREE_TYPE (decl);
+ if (POINTER_TYPE_P (type) && TYPE_RESTRICT (type)
+ && !TYPE_READONLY (TREE_TYPE (type)))
+ warn_for_restrict (param_pos, args);
+ }
+
+ FOR_EACH_VEC_SAFE_ELT (args, i, arg)
+ TREE_VISITED (arg) = 0;
+ }
+
if (TREE_CODE (postfix_expression) == COMPONENT_REF)
{
tree instance = TREE_OPERAND (postfix_expression, 0);