aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-08-21 16:53:10 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-08-21 16:53:10 +0000
commit2f687306d7dbbae7ad45e79dafde45f7b97f03c4 (patch)
treed1aa58c4e1d14ee0744cdc88ea1963f05a0690f6 /gcc/c
parent453773df32204ae524683b098444c2fa4ace8033 (diff)
downloadgcc-2f687306d7dbbae7ad45e79dafde45f7b97f03c4.zip
gcc-2f687306d7dbbae7ad45e79dafde45f7b97f03c4.tar.gz
gcc-2f687306d7dbbae7ad45e79dafde45f7b97f03c4.tar.bz2
c-family/c/c++: pass optional vec<location_t> to c-format.c
This patch passes along the vec<location_t> of argument locations at a callsite from the C frontend to check_function_arguments and from there to c-format.c, so that we can underline the pertinent argument to mismatched format codes even for tree codes like decls and constants which lack a location_t for their usage sites. This takes e.g.: printf("hello %i %i %i ", foo, bar, baz); ~^ %s to: printf("hello %i %i %i ", foo, bar, baz); ~^ ~~~ %s which is useful for cases where there's more than one variadic argument. gcc/c-family/ChangeLog: * c-common.c (check_function_arguments): Add "arglogs" param; pass it to check_function_format. * c-common.h (check_function_arguments): Add vec<location_t> * param. (check_function_format): Likewise. * c-format.c (struct format_check_context): Add field "arglocs". (check_function_format): Add param "arglocs"; pass it to check_format_info. (check_format_info): Add param "arglocs"; use it to initialize new field of format_ctx. (check_format_arg): Pass format_ctx->arglocs to new param of check_format_info_main. (class argument_parser): New field "arglocs". (argument_parser::argument_parser): Add "arglocs_" param and use it to initialize new field. (argument_parser::check_argument_type): Pass new arglocs field to check_format_types. (check_format_info_main): Add param "arglocs", and use it when constructing arg_parser. (check_format_types): Add param "arglocs"; use it if non-NULL when !EXPR_HAS_LOCATION (cur_param) to get at location information. gcc/c/ChangeLog: * c-typeck.c (build_function_call_vec): Pass arg_loc to call to check_function_arguments. gcc/cp/ChangeLog: * call.c (build_over_call): Pass NULL for new parameter to check_function_arguments. * typeck.c (cp_build_function_call_vec): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/format/diagnostic-ranges.c: Update expected results to show underlining of all pertinent params. * gcc.dg/format/pr72858.c: Likewise. From-SVN: r251238
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-typeck.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 9dcd1c3..64497a2 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-21 David Malcolm <dmalcolm@redhat.com>
+
+ * c-typeck.c (build_function_call_vec): Pass arg_loc to call
+ to check_function_arguments.
+
2017-08-18 Marek Polacek <polacek@redhat.com>
* c-parser.c (c_parser_postfix_expression): Remove unused code. Update
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index c33601f..d7ca148 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -3118,7 +3118,7 @@ build_function_call_vec (location_t loc, vec<location_t> arg_loc,
/* Check that the arguments to the function are valid. */
bool warned_p = check_function_arguments (loc, fundecl, fntype,
- nargs, argarray);
+ nargs, argarray, &arg_loc);
if (name != NULL_TREE
&& !strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10))