call.c (build_over_call), [...]): Call check_function_arguments instead of check_func...
authorJoseph Myers <jsm@polyomino.org.uk>
Wed, 30 Jun 2004 22:30:34 +0000 (23:30 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Wed, 30 Jun 2004 22:30:34 +0000 (23:30 +0100)
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
gcc/cp/call.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/nonnull1.C [new file with mode: 0644]

index 4174c4028bb29e259beed940d6e8b1d59c100a89..4d15664a4b372f6ab720e8a6fc4d410b086f7298 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-30  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * 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  <jsm@polyomino.org.uk>
 
        * call.c (build_over_call), typeck.c (build_function_call): Update
index 290fd6b2b43c0dd708a66be203633e17fbec8c73..76f0291a5a1b94099bc93e494cbe038762737299 100644 (file)
@@ -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.  */
index 1dfb3375067da62e3163b70894fc4951047509a1..d099980e486aa841e2f2dcfeca07910d507e4fad 100644 (file)
@@ -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);
 }
index 69d8c1926e25cab83f36647acc14e54cafb8fd6b..b08ec7d199d21ed01403b84d2e3c892606db0b89 100644 (file)
@@ -1,3 +1,7 @@
+2004-06-30  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * g++.dg/warn/nonnull1.C: New test.
+
 2004-06-30  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * 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 (file)
index 0000000..46de7e9
--- /dev/null
@@ -0,0 +1,16 @@
+// Test that "nonnull" attribute works for C++.
+// Origin: Joseph Myers <jsm@polyomino.org.uk>
+// { 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" }
+}