From dd66b8e81e3182b520ea5de41e1f45ba8eaedf5d Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 30 Jun 2004 23:30:34 +0100 Subject: [PATCH] call.c (build_over_call), [...]): Call check_function_arguments instead of check_function_format. cp: * call.c (build_over_call), typeck.c (build_function_call): Call check_function_arguments instead of check_function_format. testsuite: * g++.dg/warn/nonnull1.C: New test. From-SVN: r83937 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 5 ++--- gcc/cp/typeck.c | 6 +++--- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/warn/nonnull1.C | 16 ++++++++++++++++ 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/nonnull1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4174c4028bb..4d15664a4b3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-06-30 Joseph S. Myers + + * call.c (build_over_call), typeck.c (build_function_call): Call + check_function_arguments instead of check_function_format. + 2004-06-30 Joseph S. Myers * call.c (build_over_call), typeck.c (build_function_call): Update diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 290fd6b2b43..76f0291a5a1 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4723,9 +4723,8 @@ build_over_call (struct z_candidate *cand, int flags) converted_args = nreverse (converted_args); - if (warn_format) - check_function_format (TYPE_ATTRIBUTES (TREE_TYPE (fn)), - converted_args); + check_function_arguments (TYPE_ATTRIBUTES (TREE_TYPE (fn)), + converted_args); /* Avoid actually calling copy constructors and copy assignment operators, if possible. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1dfb3375067..d099980e486 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2483,10 +2483,10 @@ build_function_call (tree function, tree params) if (coerced_params == error_mark_node) return error_mark_node; - /* Check for errors in format strings. */ + /* Check for errors in format strings and inappropriately + null parameters. */ - if (warn_format) - check_function_format (TYPE_ATTRIBUTES (fntype), coerced_params); + check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params); return build_cxx_call (function, coerced_params); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 69d8c1926e2..b08ec7d199d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-06-30 Joseph S. Myers + + * g++.dg/warn/nonnull1.C: New test. + 2004-06-30 Eric Botcazou * gcc.dg/compat/compat-common.h: Wrap up CINT in diff --git a/gcc/testsuite/g++.dg/warn/nonnull1.C b/gcc/testsuite/g++.dg/warn/nonnull1.C new file mode 100644 index 00000000000..46de7e9312c --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/nonnull1.C @@ -0,0 +1,16 @@ +// Test that "nonnull" attribute works for C++. +// Origin: Joseph Myers +// { dg-do compile } +// { dg-options "-Wall" } + +// The "nonnull" attribute is thoroughly tested for C, so here we +// simply test that it works at all, as at one point the relevant +// checking code was only called for C. + +extern void f (char *) __attribute__((nonnull)); + +void +g () +{ + f (0); // { dg-warning "null" "null argument" } +} -- 2.30.2