Index: generic/tcl.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
retrieving revision 1.311
diff -u -r1.311 tcl.h
--- generic/tcl.h	14 Dec 2010 21:51:53 -0000	1.311
+++ generic/tcl.h	18 Jan 2011 08:49:47 -0000
@@ -158,6 +158,11 @@
 #    define TCL_VARARGS_DEF(type, name) (type name, ...)
 #    define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
 #endif
+#if defined(__GNUC__) && (__GNUC__ > 2)
+#   define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+#else
+#   define TCL_FORMAT_PRINTF(a,b)
+#endif
 
 /*
  *----------------------------------------------------------------------------
Index: generic/tclDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclDecls.h,v
retrieving revision 1.188
diff -u -r1.188 tclDecls.h
--- generic/tclDecls.h	4 Nov 2010 21:48:23 -0000	1.188
+++ generic/tclDecls.h	18 Jan 2011 08:49:49 -0000
@@ -46,7 +46,7 @@
 				const char *name, const char *version,
 				int exact, void *clientDataPtr);
 /* 2 */
-EXTERN void		Tcl_Panic(const char *format, ...);
+EXTERN void		Tcl_Panic(const char *format, ...) TCL_FORMAT_PRINTF(1, 2);
 /* 3 */
 EXTERN char *		Tcl_Alloc(unsigned int size);
 /* 4 */
@@ -1664,10 +1664,10 @@
 				Tcl_Obj *objPtr, const char *format,
 				int objc, Tcl_Obj *const objv[]);
 /* 578 */
-EXTERN Tcl_Obj *	Tcl_ObjPrintf(const char *format, ...);
+EXTERN Tcl_Obj *	Tcl_ObjPrintf(const char *format, ...) TCL_FORMAT_PRINTF(1, 2);
 /* 579 */
 EXTERN void		Tcl_AppendPrintfToObj(Tcl_Obj *objPtr,
-				const char *format, ...);
+				const char *format, ...) TCL_FORMAT_PRINTF(2, 3);
 /* 580 */
 EXTERN int		Tcl_CancelEval(Tcl_Interp *interp,
 				Tcl_Obj *resultObjPtr, ClientData clientData,
@@ -1822,7 +1822,7 @@
 
     int (*tcl_PkgProvideEx) (Tcl_Interp *interp, const char *name, const char *version, const void *clientData); /* 0 */
     CONST84_RETURN char * (*tcl_PkgRequireEx) (Tcl_Interp *interp, const char *name, const char *version, int exact, void *clientDataPtr); /* 1 */
-    void (*tcl_Panic) (const char *format, ...); /* 2 */
+    void (*tcl_Panic) (const char *format, ...) TCL_FORMAT_PRINTF(1, 2); /* 2 */
     char * (*tcl_Alloc) (unsigned int size); /* 3 */
     void (*tcl_Free) (char *ptr); /* 4 */
     char * (*tcl_Realloc) (char *ptr, unsigned int size); /* 5 */
@@ -2422,8 +2422,8 @@
     void (*tcl_AppendLimitedToObj) (Tcl_Obj *objPtr, const char *bytes, int length, int limit, const char *ellipsis); /* 575 */
     Tcl_Obj * (*tcl_Format) (Tcl_Interp *interp, const char *format, int objc, Tcl_Obj *const objv[]); /* 576 */
     int (*tcl_AppendFormatToObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, const char *format, int objc, Tcl_Obj *const objv[]); /* 577 */
-    Tcl_Obj * (*tcl_ObjPrintf) (const char *format, ...); /* 578 */
-    void (*tcl_AppendPrintfToObj) (Tcl_Obj *objPtr, const char *format, ...); /* 579 */
+    Tcl_Obj * (*tcl_ObjPrintf) (const char *format, ...) TCL_FORMAT_PRINTF(1, 2); /* 578 */
+    void (*tcl_AppendPrintfToObj) (Tcl_Obj *objPtr, const char *format, ...) TCL_FORMAT_PRINTF(2, 3); /* 579 */
     int (*tcl_CancelEval) (Tcl_Interp *interp, Tcl_Obj *resultObjPtr, ClientData clientData, int flags); /* 580 */
     int (*tcl_Canceled) (Tcl_Interp *interp, int flags); /* 581 */
     int (*tcl_CreatePipe) (Tcl_Interp *interp, Tcl_Channel *rchan, Tcl_Channel *wchan, int flags); /* 582 */
Index: tools/genStubs.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tools/genStubs.tcl,v
retrieving revision 1.44
diff -u -r1.44 genStubs.tcl
--- tools/genStubs.tcl	15 Sep 2010 07:33:56 -0000	1.44
+++ tools/genStubs.tcl	18 Jan 2011 08:49:49 -0000
@@ -491,6 +491,9 @@
 		set sep ", "
 	    }
 	    append line ", ...)"
+	    if {[lindex $args end] eq "{const char *} format"} {
+		    append line " TCL_FORMAT_PRINTF(" [expr [llength $args] - 1] ", " [llength $args] ")"
+	    }
 	}
 	default {
 	    set sep "("
@@ -588,6 +591,9 @@
 		set sep ", "
 	    }
 	    append text ", ...)"
+	    if {[lindex $args end] eq "{const char *} format"} {
+		    append text " TCL_FORMAT_PRINTF(" [expr [llength $args] - 1] ", " [llength $args] ")"
+	    }
 	}
 	default {
 	    set sep "("
