cex: rename -Wcounterexample as -Wcounterexamples, and support -Wcex

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
commit d2acc4b4014ad7447c29ce56095f28d22ed12978
Author: Akim Demaille <[email protected]>
Date:   Wed Jun 10 07:35:47 2020 +0200

    cex: rename -Wcounterexample as -Wcounterexamples, and support -Wcex
    
    Plural vs. singular is always a problem...
    
    But we already have conflicts-sr and conflicts-rr, so counterexamples
    makes more sense than counterexample.  Besides, -Wcounterexample will
    still be accepted as an unambiguous prefix of -Wcounterexamples.
    
    Add -Wcex as a convenient alias.
    
    While at it, use only "counterexample", never "counter example".
    
    * src/complain.h, src/complain.c
    (Wcounterexample, warning_counterexample): Rename as...
    (Wcounterexamples, warning_counterexamples): these.
    (argmatch_warning_docs): Rename -Wcounterexample as -Wcounterexamples.
    (argmatch_warning_args): Likewise.
    Add support for -Wcex.
    Adjust dependencies.

diff --git a/src/complain.c b/src/complain.c
index 1c2ba797..92d5fc52 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -114,7 +114,7 @@ static const argmatch_warning_doc argmatch_warning_docs[] =
 {
   { "conflicts-sr",     N_("S/R conflicts (enabled by default)") },
   { "conflicts-rr",     N_("R/R conflicts (enabled by default)") },
-  { "counterexample",   N_("Conflict counter examples") },
+  { "counterexamples",  N_("generate conflict counterexamples") },
   { "dangling-alias",   N_("string aliases not attached to a symbol") },
   { "deprecated",       N_("obsolete constructs") },
   { "empty-rule",       N_("empty rules without %empty") },
@@ -122,7 +122,7 @@ static const argmatch_warning_doc argmatch_warning_docs[] =
   { "precedence",       N_("useless precedence and associativity") },
   { "yacc",             N_("incompatibilities with POSIX Yacc") },
   { "other",            N_("all other warnings (enabled by default)") },
-  { "all",              N_("all the warnings except 'dangling-alias' and 'yacc'") },
+  { "all",              N_("all the warnings except 'counterexamples', 'dangling-alias' and 'yacc'") },
   { "no-CATEGORY",      N_("turn off warnings in CATEGORY") },
   { "none",             N_("turn off all the warnings") },
   { "error[=CATEGORY]", N_("treat warnings as errors") },
@@ -131,19 +131,19 @@ static const argmatch_warning_doc argmatch_warning_docs[] =
 
 static const argmatch_warning_arg argmatch_warning_args[] =
 {
-  { "all",            Wall },
-  { "conflicts-rr",   Wconflicts_rr },
-  { "conflicts-sr",   Wconflicts_sr },
-  { "counterexample", Wcounterexample },
-  { "dangling-alias", Wdangling_alias },
-  { "deprecated",     Wdeprecated },
-  { "empty-rule",     Wempty_rule },
-  { "everything",     Weverything },
-  { "midrule-values", Wmidrule_values },
-  { "none",           Wnone },
-  { "other",          Wother },
-  { "precedence",     Wprecedence },
-  { "yacc",           Wyacc },
+  { "all",             Wall },
+  { "conflicts-rr",    Wconflicts_rr },
+  { "conflicts-sr",    Wconflicts_sr },
+  { "counterexamples", Wcounterexamples }, { "cex", Wcounterexamples }, // Show cex second.
+  { "dangling-alias",  Wdangling_alias },
+  { "deprecated",      Wdeprecated },
+  { "empty-rule",      Wempty_rule },
+  { "everything",      Weverything },
+  { "midrule-values",  Wmidrule_values },
+  { "none",            Wnone },
+  { "other",           Wother },
+  { "precedence",      Wprecedence },
+  { "yacc",            Wyacc },
   { NULL, Wnone }
 };
 
diff --git a/src/complain.h b/src/complain.h
index 63a14f76..eab5720d 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -46,7 +46,7 @@ typedef enum
   {
     warning_conflicts_rr,
     warning_conflicts_sr,
-    warning_counterexample,
+    warning_counterexamples,
     warning_dangling_alias,
     warning_deprecated,
     warning_empty_rule,
@@ -107,7 +107,7 @@ typedef enum
 
     Wconflicts_rr     = 1 << warning_conflicts_rr,
     Wconflicts_sr     = 1 << warning_conflicts_sr,
-    Wcounterexample   = 1 << warning_counterexample,
+    Wcounterexamples  = 1 << warning_counterexamples,
     Wdangling_alias   = 1 << warning_dangling_alias,
     Wdeprecated       = 1 << warning_deprecated,
     Wempty_rule       = 1 << warning_empty_rule,
@@ -124,7 +124,7 @@ typedef enum
 
     /**< All above warnings.  */
     Weverything       = ~complaint & ~fatal & ~silent,
-    Wall              = Weverything & ~Wcounterexample & ~Wdangling_alias & ~Wyacc
+    Wall              = Weverything & ~Wcounterexamples & ~Wdangling_alias & ~Wyacc
   } warnings;
 
 /** Whether the warnings of \a flags are all unset.
diff --git a/src/conflicts.c b/src/conflicts.c
index 2f8b7c53..7becadb2 100644
--- a/src/conflicts.c
+++ b/src/conflicts.c
@@ -723,7 +723,7 @@ rule_conflicts_print (void)
                       r->code, rr, expected_rr);
         }
     }
-  if (warning_is_enabled (Wcounterexample))
+  if (warning_is_enabled (Wcounterexamples))
     report_counterexamples ();
 }
 
diff --git a/src/counterexample.c b/src/counterexample.c
index 031681ea..5ff1e9fd 100644
--- a/src/counterexample.c
+++ b/src/counterexample.c
@@ -1036,7 +1036,7 @@ generate_next_states (search_state *ss, state_item *conflict1,
 }
 
 /*
- * Perform the actual counter example search,
+ * Perform the actual counterexample search,
  * keeps track of what stage of the search algorithm
  * we are at and gives the appropriate counterexample
  * type based off of time constraints.
diff --git a/src/main.c b/src/main.c
index 30e3ca69..5dd54d34 100644
--- a/src/main.c
+++ b/src/main.c
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
       conflicts_update_state_numbers (old_to_new, nstates_old);
       free (old_to_new);
     }
-  if (warning_is_enabled (Wcounterexample))
+  if (warning_is_enabled (Wcounterexamples))
     counterexample_init ();
   conflicts_print ();
   timevar_pop (tv_conflicts);
diff --git a/tests/counterexample.at b/tests/counterexample.at
index 7c176636..8647e464 100644
--- a/tests/counterexample.at
+++ b/tests/counterexample.at
@@ -21,7 +21,7 @@ m4_define([AT_BISON_CHECK_CEX],
 [AT_DATA([experr], [$4])
 sed -e ['s/time limit exceeded: [0-9][.0-9]*/time limit exceeded: XXX/g'] \
   experr >expout
-AT_BISON_CHECK([-Wcounterexample $1], [$2], [$3], [stderr])
+AT_BISON_CHECK([-Wcounterexamples $1], [$2], [$3], [stderr])
 AT_CHECK([[sed -e 's/time limit exceeded: [0-9][.0-9]*/time limit exceeded: XXX/g' stderr]],
          [], [expout])
 ])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.