If tags are explicitly enabled, re2c should always fail with error
on nondeterministic tags. There's no good in '-Werror-nondeterministic-tags'
diagnostic --- the user cannot reset it anyway.
This commit fixes unsuccessful attempt
2bfe75d57c71c7102dd6e7b4e5f7139411c7c080
"Restore user warnings after temporarily enforcing a warning.", which
resulted in hiding tag errors if '-Wnondeterministic-tags' is not set.
const std::string &cond,
const std::string *tagname)
{
- if (mask[NONDETERMINISTIC_TAGS] & WARNING)
- {
- bool e = mask[NONDETERMINISTIC_TAGS] & ERROR;
-
- // a very bad hack to temporarily turn on -Werror
- // TODO: userwarn/realwarn (like useropt/realopt)
- if (opts->tags) {
- e = true;
+ if (opts->tags) {
+ error_accuml = true;
+ if (tagname == NULL) {
+ re2c::error("line %u: trailing context %sis nondeterministic",
+ line, incond(cond).c_str());
+ } else {
+ re2c::error("line %u: tag '%s' %sis nondeterministic",
+ line, tagname->c_str(), incond(cond).c_str());
}
-
+ } else if (mask[NONDETERMINISTIC_TAGS] & WARNING) {
+ bool e = mask[NONDETERMINISTIC_TAGS] & ERROR;
error_accuml |= e;
-
if (tagname == NULL) {
warning(names[NONDETERMINISTIC_TAGS], line, e,
"trailing context %sis nondeterministic",
-re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
+re2c: error: line 2: tag 'p' is nondeterministic
-re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
+re2c: error: line 2: tag 'p' is nondeterministic
-re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
+re2c: error: line 2: tag 'p' is nondeterministic
-re2c: error: line 7: trailing context is nondeterministic [-Werror-nondeterministic-tags]
+re2c: error: line 7: trailing context is nondeterministic
re2c: warning: line 13: trailing context is nondeterministic [-Wnondeterministic-tags]
-re2c: error: line 4: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
+re2c: error: line 4: tag 'p' is nondeterministic
-re2c: error: line 5: tag 'b' is nondeterministic [-Werror-nondeterministic-tags]
-re2c: error: line 6: tag 'e' is nondeterministic [-Werror-nondeterministic-tags]
-re2c: error: line 8: tag 'c' is nondeterministic [-Werror-nondeterministic-tags]
-re2c: error: line 9: tag 'f' is nondeterministic [-Werror-nondeterministic-tags]
+re2c: error: line 5: tag 'b' is nondeterministic
+re2c: error: line 6: tag 'e' is nondeterministic
+re2c: error: line 8: tag 'c' is nondeterministic
+re2c: error: line 9: tag 'f' is nondeterministic
re2c: warning: line 2: rule matches empty string [-Wmatch-empty-string]
re2c: warning: line 3: rule matches empty string [-Wmatch-empty-string]
re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string]