comparison gen/warnings.cpp @ 1568:a591aa6bd6dc

Forgot to add files.
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Thu, 06 Aug 2009 17:04:36 +0200
parents
children
comparison
equal deleted inserted replaced
1567:f1f33c8dcd90 1568:a591aa6bd6dc
1 #include "mars.h"
2 #include "mtype.h"
3 #include "expression.h"
4
5 #include "gen/warnings.h"
6
7 void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs)
8 {
9 Expression* arg = arguments;
10
11 // make sure first argument is a string literal, or we can't do much
12 // TODO make it smarter ?
13 if (arg->op != TOKstring)
14 return; // assume valid
15
16 StringExp* strexp = (StringExp*)arg;
17
18 // not wchar or dhar
19 if (strexp->sz != 1)
20 {
21 warning(loc, "printf does not support wchar and dchar strings");
22 return;
23 }
24
25 #if 0
26 // check the format string
27 const char* str = (char*)strexp->string;
28 for (size_t i = 0; i < strexp->len; ++i)
29 {
30 // TODO
31 }
32 #endif
33 }