Report an error rather than a warning (at least GCC does so).
error ("only one of switches -e, -w, -x, -u and -8 must be set");
}
-void warning (const char * type, uint32_t line, const char * fmt, ...)
+void warning (const char * type, uint32_t line, bool error, const char * fmt, ...)
{
- fprintf (stderr, "re2c: warning: line %u: ", line);
+ static const char * msg = error ? "error" : "warning";
+ fprintf (stderr, "re2c: %s: line %u: ", msg, line);
va_list args;
va_start (args, fmt);
vfprintf (stderr, fmt, args);
va_end (args);
- fprintf (stderr, " [-W%s]\n", type);
+ const char * prefix = error ? "error-" : "";
+ fprintf (stderr, " [-W%s%s]\n", prefix, type);
}
void usage ()
void error (const char * fmt, ...) RE2C_GXX_ATTRIBUTE ((format (printf, 1, 2)));
void error_encoding ();
-void warning (const char * type, uint32_t line, const char * fmt, ...) RE2C_GXX_ATTRIBUTE ((format (printf, 3, 4)));
+void warning (const char * type, uint32_t line, bool error, const char * fmt, ...) RE2C_GXX_ATTRIBUTE ((format (printf, 4, 5)));
void usage ();
void vernum ();
void version ();
{
if (mask[EMPTY_CHARACTER_CLASS] & WARNING)
{
- if (mask[EMPTY_CHARACTER_CLASS] & ERROR)
- {
- error_accuml = true;
- }
- warning (names[EMPTY_CHARACTER_CLASS], line, "empty character class");
+ const bool e = mask[EMPTY_CHARACTER_CLASS] & ERROR;
+ error_accuml |= e;
+ warning (names[EMPTY_CHARACTER_CLASS], line, e, "empty character class");
}
}
{
if (mask[MATCH_EMPTY_STRING] & WARNING)
{
- if (mask[MATCH_EMPTY_STRING] & ERROR)
- {
- error_accuml = true;
- }
- warning (names[MATCH_EMPTY_STRING], line, "rule matches empty string");
+ const bool e = mask[MATCH_EMPTY_STRING] & ERROR;
+ error_accuml |= e;
+ warning (names[MATCH_EMPTY_STRING], line, e, "rule matches empty string");
}
}
{
if (mask[NAKED_DEFAULT] & WARNING)
{
- if (mask[NAKED_DEFAULT] & ERROR)
- {
- error_accuml = true;
- }
+ const bool e = mask[NAKED_DEFAULT] & ERROR;
+ error_accuml |= e;
std::ostringstream cunits;
for (uint32_t i = 0; i < stray_cunits.size (); ++i)
{
warning
( names[NAKED_DEFAULT]
, line
+ , e
, "naked default case%s%s (stray code units: %s), better add default rule *"
, cond_prefix
, cond.c_str ()