aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
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/c/c-parser.c
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/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 6bc42da..52a5edd 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -8451,6 +8451,28 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
warn_for_memset (expr_loc, arg0, arg2, literal_zero_mask);
}
+ if (TREE_CODE (expr.value) == FUNCTION_DECL && warn_restrict)
+ {
+ unsigned i;
+ tree arg;
+ FOR_EACH_VEC_SAFE_ELT (exprlist, i, arg)
+ TREE_VISITED (arg) = 0;
+
+ unsigned param_pos = 0;
+ function_args_iterator iter;
+ tree t;
+ FOREACH_FUNCTION_ARGS (TREE_TYPE (expr.value), t, iter)
+ {
+ if (POINTER_TYPE_P (t) && TYPE_RESTRICT (t)
+ && !TYPE_READONLY (TREE_TYPE (t)))
+ warn_for_restrict (param_pos, exprlist);
+ param_pos++;
+ }
+
+ FOR_EACH_VEC_SAFE_ELT (exprlist, i, arg)
+ TREE_VISITED (arg) = 0;
+ }
+
start = expr.get_start ();
finish = parser->tokens_buf[0].get_finish ();
expr.value