From 58e72047f53213e010d649cc220f63b2dce07134 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 11 Feb 2010 20:43:39 -0500 Subject: Add printf-style warnings to dmnsn_diagnostic, and fix bugs it found. --- dimension/parse.c | 5 +++-- dimension/utility.h | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dimension/parse.c b/dimension/parse.c index 6ca6326..ac74568 100644 --- a/dimension/parse.c +++ b/dimension/parse.c @@ -443,7 +443,8 @@ dmnsn_eval_unary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable) "expected %s, %s, or %s; found %s", dmnsn_astnode_string(DMNSN_AST_INTEGER), dmnsn_astnode_string(DMNSN_AST_FLOAT), - dmnsn_astnode_string(DMNSN_AST_VECTOR)); + dmnsn_astnode_string(DMNSN_AST_VECTOR), + dmnsn_astnode_string(rhs.type)); ret = dmnsn_copy_astnode(astnode); ret.type = DMNSN_AST_NONE; } @@ -811,7 +812,7 @@ dmnsn_eval(dmnsn_astnode astnode, dmnsn_symbol_table *symtable) return dmnsn_eval(*symbol, symtable); } else { dmnsn_diagnostic(astnode.filename, astnode.line, astnode.col, - "Unbound identifier '%s'", astnode.ptr); + "Unbound identifier '%s'", (const char *)astnode.ptr); dmnsn_astnode error = dmnsn_new_astnode(DMNSN_AST_NONE); ++*error.refcount; return error; diff --git a/dimension/utility.h b/dimension/utility.h index c26069c..d4ebda4 100644 --- a/dimension/utility.h +++ b/dimension/utility.h @@ -17,6 +17,11 @@ * along with this program. If not, see . * *************************************************************************/ +#ifndef __GNUC__ + #define __attribute__(x) +#endif + /* Print a parsing diagnostic to stderr */ void dmnsn_diagnostic(const char *filename, int line, int col, - const char *format, ...); + const char *format, ...) + __attribute__ ((format (printf, 4, 5))); -- cgit v1.2.3