Patch to add missing format attributes

Joseph S. Myers jsm28@cam.ac.uk
Sat Oct 21 06:55:00 GMT 2000


This patch adds missing format attributes to GCC that were found by
-Wmissing-format-attribute.  There were no false positives (and no broken
format strings in GCC detected by these additions).

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

gcc/ChangeLog:
2000-10-21  Joseph S. Myers  <jsm28@cam.ac.uk>

	* cpplib.h (cpp_printf): Add ATTRIBUTE_PRINTF_3.
	* diagnostic.c (vbuild_message_string, output_do_printf, vnotice):
	Add ATTRIBUTE_PRINTF.
	* tradcpp.c (v_message, warning, error, fatal, error_with_line):
	Add ATTRIBUTE_PRINTF*.

gcc/java/ChangeLog:
2000-10-21  Joseph S. Myers  <jsm28@cam.ac.uk>

	* parse.y (issue_warning_error_from_context): Add
	ATTRIBUTE_PRINTF.

--- cpplib.h.orig	Tue Sep 26 08:12:14 2000
+++ cpplib.h	Fri Oct 20 16:56:27 2000
@@ -751,7 +751,8 @@
 extern int cpp_ideq			PARAMS ((const cpp_token *,
 						 const char *));
 extern void cpp_printf			PARAMS ((cpp_reader *, cpp_printer *,
-						 const char *, ...));
+						 const char *, ...))
+     ATTRIBUTE_PRINTF_3;
 
 extern void cpp_output_list		PARAMS ((cpp_reader *, FILE *,
 						 const cpp_toklist *,
--- diagnostic.c.orig	Fri Oct 20 18:08:08 2000
+++ diagnostic.c	Fri Oct 20 18:52:44 2000
@@ -69,15 +69,18 @@
 static void output_format PARAMS ((output_buffer *));
 static void output_indent PARAMS ((output_buffer *));
 
-static char *vbuild_message_string PARAMS ((const char *, va_list));
+static char *vbuild_message_string PARAMS ((const char *, va_list))
+     ATTRIBUTE_PRINTF (1, 0);
 static char *build_message_string PARAMS ((const char *, ...))
      ATTRIBUTE_PRINTF_1;
-static void output_do_printf PARAMS ((output_buffer *, const char *));
+static void output_do_printf PARAMS ((output_buffer *, const char *))
+     ATTRIBUTE_PRINTF (2, 0);
 static void format_with_decl PARAMS ((output_buffer *, tree));
 static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
 static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, int));
 static void diagnostic_for_decl PARAMS ((tree, const char *, va_list *, int));
-static void vnotice PARAMS ((FILE *, const char *, va_list));
+static void vnotice PARAMS ((FILE *, const char *, va_list))
+     ATTRIBUTE_PRINTF (2, 0);
 static void set_real_maximum_length PARAMS ((output_buffer *));
                                           
 static void output_unsigned_decimal PARAMS ((output_buffer *, unsigned int));
--- tradcpp.c.orig	Fri Sep  1 17:48:16 2000
+++ tradcpp.c	Fri Oct 20 18:55:11 2000
@@ -328,12 +328,15 @@
 /* First arg to v_message.  */
 enum msgtype { WARNING = 0, ERROR, FATAL };
 void v_message		 PARAMS ((enum msgtype mtype, int line,
-				  const char *msgid, va_list ap));
+				  const char *msgid, va_list ap))
+     ATTRIBUTE_PRINTF (3, 0);
 
-void warning		 PARAMS ((const char *msgid, ...));
-void error		 PARAMS ((const char *msgid, ...));
-void fatal		 PARAMS ((const char *msgid, ...)) ATTRIBUTE_NORETURN;
-void error_with_line	 PARAMS ((int, const char *msgid, ...));
+void warning		 PARAMS ((const char *msgid, ...)) ATTRIBUTE_PRINTF_1;
+void error		 PARAMS ((const char *msgid, ...)) ATTRIBUTE_PRINTF_1;
+void fatal		 PARAMS ((const char *msgid, ...)) ATTRIBUTE_NORETURN
+     ATTRIBUTE_PRINTF_1;
+void error_with_line	 PARAMS ((int, const char *msgid, ...))
+     ATTRIBUTE_PRINTF_2;
 void error_from_errno	 PARAMS ((const char *msgid));
 
 void perror_with_name 	 PARAMS ((const char *msgid));
--- java/parse.y.orig	Fri Oct 20 06:38:05 2000
+++ java/parse.y	Fri Oct 20 16:54:29 2000
@@ -93,7 +93,8 @@
 static tree method_declarator PARAMS ((tree, tree));
 static void parse_warning_context PARAMS ((tree cl, const char *msg, ...))
   ATTRIBUTE_PRINTF_2;
-static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list));
+static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list))
+  ATTRIBUTE_PRINTF (2, 0);
 static void parse_ctor_invocation_error PARAMS ((void));
 static tree parse_jdk1_1_error PARAMS ((const char *));
 static void complete_class_report_errors PARAMS ((jdep *));

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list