diff dmd/mars.h @ 1372:229e02867307

Fix format-string bugs by adding __attribute__((__format__)) in all applicable places and fixing all warnings my gcc produced. Among other things, this should fix several segfaults (including one I just ran into).
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 17 May 2009 00:15:25 +0200
parents 8026319762be
children 1311dabc6a1f
line wrap: on
line diff
--- a/dmd/mars.h	Sat May 16 23:44:27 2009 +0200
+++ b/dmd/mars.h	Sun May 17 00:15:25 2009 +0200
@@ -76,6 +76,14 @@
 #endif
 #endif
 
+#ifndef IS_PRINTF
+# ifdef __GNUC__
+#  define IS_PRINTF(FMTARG) __attribute((__format__ (__printf__, (FMTARG), (FMTARG)+1) ))
+# else
+#  define IS_PRINTF(FMTARG)
+# endif
+#endif
+
 #ifdef IN_GCC
 /* Changes for the GDC compiler by David Friedman */
 #endif
@@ -395,9 +403,9 @@
     MATCHexact		// exact match
 };
 
-void warning(Loc loc, const char *format, ...);
+void warning(Loc loc, const char *format, ...) IS_PRINTF(2);
 void vwarning(Loc loc, const char *format, va_list);
-void error(Loc loc, const char *format, ...);
+void error(Loc loc, const char *format, ...) IS_PRINTF(2);
 void verror(Loc loc, const char *format, va_list);
 void fatal();
 void err_nomem();