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]
Other format: [Raw text]

[LIBIBERTY PATCH]: Add ATTRIBUTE_FPTR_PRINTF macro


Using attribute printf on function pointers became valid in GCC as of
version 3.1.x AFAICT.  I haven't found a place in GCC to use this yet,
but I'd like to have the functionality implemented just in case.  Plus
other clients of libiberty may find it useful.

Bootstrapped on x86_64-unknown-linux-gnu.

Okay for mainline?

		Thanks,
		--Kaveh


2005-05-29  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* ansidecl.h: Add ATTRIBUTE_FPTR_PRINTF.

diff -rup orig/egcc-CVS20050526/include/ansidecl.h egcc-CVS20050526/include/ansidecl.h
--- orig/egcc-CVS20050526/include/ansidecl.h	2005-05-24 22:01:49.000000000 -0400
+++ egcc-CVS20050526/include/ansidecl.h	2005-05-27 10:09:04.000000000 -0400
@@ -312,6 +312,22 @@ So instead we use the macro below and te
 #define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
 #endif /* ATTRIBUTE_PRINTF */
 
+/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
+   a function pointer.  Format attributes were allowed on function
+   pointers as of gcc 3.1.  */
+#ifndef ATTRIBUTE_FPTR_PRINTF
+# if (GCC_VERSION >= 3001)
+#  define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
+# else
+#  define ATTRIBUTE_FPTR_PRINTF(m, n)
+# endif /* GNUC >= 3.1 */
+# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
+# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
+# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
+# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
+# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
+#endif /* ATTRIBUTE_FPTR_PRINTF */
+
 /* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
    NULL format specifier was allowed as of gcc 3.3.  */
 #ifndef ATTRIBUTE_NULL_PRINTF


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