From 1224f5b8cb984d53fcd27fc2a0d906e0fec8025b Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Wed, 11 May 2016 16:49:59 +0100 Subject: [PATCH] Don't use '-Werror-nondeterministic-tags' with '-T, --tags'. 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. --- re2c/src/conf/warn.cc | 20 ++++++++++---------- re2c/test/tags/nondet_alt1.--tags.c | 2 +- re2c/test/tags/nondet_alt2.--tags.c | 2 +- re2c/test/tags/nondet_cat1.--tags.c | 2 +- re2c/test/tags/nondet_cat2.c | 2 +- re2c/test/tags/nondet_cat4.--tags.c | 2 +- re2c/test/tags/nondet_iter.--tags.c | 8 ++++---- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/re2c/src/conf/warn.cc b/re2c/src/conf/warn.cc index 0599d167..5810f129 100644 --- a/re2c/src/conf/warn.cc +++ b/re2c/src/conf/warn.cc @@ -124,18 +124,18 @@ void Warn::nondeterministic_tags( 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", diff --git a/re2c/test/tags/nondet_alt1.--tags.c b/re2c/test/tags/nondet_alt1.--tags.c index 47a58ddd..fc1e74c7 100644 --- a/re2c/test/tags/nondet_alt1.--tags.c +++ b/re2c/test/tags/nondet_alt1.--tags.c @@ -1 +1 @@ -re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags] +re2c: error: line 2: tag 'p' is nondeterministic diff --git a/re2c/test/tags/nondet_alt2.--tags.c b/re2c/test/tags/nondet_alt2.--tags.c index 47a58ddd..fc1e74c7 100644 --- a/re2c/test/tags/nondet_alt2.--tags.c +++ b/re2c/test/tags/nondet_alt2.--tags.c @@ -1 +1 @@ -re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags] +re2c: error: line 2: tag 'p' is nondeterministic diff --git a/re2c/test/tags/nondet_cat1.--tags.c b/re2c/test/tags/nondet_cat1.--tags.c index 47a58ddd..fc1e74c7 100644 --- a/re2c/test/tags/nondet_cat1.--tags.c +++ b/re2c/test/tags/nondet_cat1.--tags.c @@ -1 +1 @@ -re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags] +re2c: error: line 2: tag 'p' is nondeterministic diff --git a/re2c/test/tags/nondet_cat2.c b/re2c/test/tags/nondet_cat2.c index d9137ba0..05c88380 100644 --- a/re2c/test/tags/nondet_cat2.c +++ b/re2c/test/tags/nondet_cat2.c @@ -1,2 +1,2 @@ -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] diff --git a/re2c/test/tags/nondet_cat4.--tags.c b/re2c/test/tags/nondet_cat4.--tags.c index 3da022eb..d2fc84aa 100644 --- a/re2c/test/tags/nondet_cat4.--tags.c +++ b/re2c/test/tags/nondet_cat4.--tags.c @@ -1 +1 @@ -re2c: error: line 4: tag 'p' is nondeterministic [-Werror-nondeterministic-tags] +re2c: error: line 4: tag 'p' is nondeterministic diff --git a/re2c/test/tags/nondet_iter.--tags.c b/re2c/test/tags/nondet_iter.--tags.c index 759a4fc6..661c10de 100644 --- a/re2c/test/tags/nondet_iter.--tags.c +++ b/re2c/test/tags/nondet_iter.--tags.c @@ -1,7 +1,7 @@ -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] -- 2.40.0