This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: __attribute__((nonnull))



  In message <200001120121.CAA13902@quatramaran.ens.fr>you write:
  > This is a multipart MIME message.
  > 
  > --==_Exmh_641849380
  > Content-Type: text
  > X-UIDL: f150f74410ce8c7e7ba6d884c7d546d9
  > 
  > Apparently, no-one wants to review that patch. Maybe with a more explicit
  > subject line, it will look nicer...
  > Anyway, after some fidgeting, I implemented the whole thing.
  > 
  > What this does:
  > * remove non-null pointer checking from format(printf), since there exist
  > some printf-like functions that accept NULL pointers (BSD4.4 warn, for 
  > instance).
  > 
  > * generalize the record_international/record_format framework so that any
  > number of attributes can be chained for a given function--might even be
  > useful per-se, as it is logically meaningful for a function to be
  > vprintf-like in its first arguments, and scanf-like in the remaining part..
  > .
  > 
  > * add a separate nonnull attribute, for functions that explicitly demand
  > non-null pointers.
  > 
  > * implement a shortcut, where attribute((nonnull)), without numeric
  > parameters, means that all pointer arguments for that function have the 
  > non-null property.
  > 
  > This patch just warns about explicit null constants.  I think that it might
  > be useful information for the compiler later on.
  > The extend.texi part only applies cleanly after my small documentation patc
  > h
  > (Subject: PATCH: reference attribute((format_arg)) properly.)
  > 
  > Wed Jan 12 02:08:26 CET 2000 Marc Espie	<espie@cvs.openbsd.org>
  > 	* c-common.c (A_NONNULL):  New attribute.
  > 	(init_attribute):  Record A_NONNULL.
  > 	(record_function_format, record_international_format):  Remove.
  > 	(insert_function_attribute):  New, replacement for record_xxx.
  > 	(function_attribute_info, function_attributes_info):  New types.
  > 	(new_function_format, new_international_format, new_nonnull_info):
  > 	Corresponding constructors.
  > 	(decl_attributes):  Handle A_NONNULL, modify A_FORMAT and
  > 	A_FORMAT_ARG for new framework.
  > 	(function_format_info, international_format_info):  Fit with
  > 	function_attribute(s)_info.
  > 	(function_attribute_list):  New variable, replaces...
  > 	(function_format_list, international_format_list):  Remove.
  > 	(add_function_format):  New, helper for init_format_info.
  > 	(init_format_info):  Adjust format attributes.
  > 	(check_function_format):  Handle A_FORMAT and A_NONNULL attributes.
  > 	(find_function_attribute, reduce_pointer):  New.
  > 	(check_nonnull_info):  New, check A_NONNULL.
  > 	(check_format_info):  Use helper functions, remove non-null pointer
  > 	checks.
  > 	* extend.texi: Document nonnull.
I believe Gavin basically approved this patch once it's documented better.

Can you please try to improve the documentation and update it for the
current sources (I tried to apply it and got numerous rejections).

Thanks,
jeff




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]