bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] use -Wdeprecated for obsolete %define variable names


From: Akim Demaille
Subject: [PATCH 3/4] use -Wdeprecated for obsolete %define variable names
Date: Tue, 4 Sep 2012 13:58:15 +0200

* src/muscle-tab.c (muscle_percent_variable_update): Here.
* tests/input.at (%define backward compatibility): Update expectations.
---
 src/muscle-tab.c | 17 ++++++++++++-----
 tests/input.at   |  9 ++++++---
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index a55b6c4..8e56981 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -388,7 +388,7 @@ muscle_user_name_list_grow (char const *key, char const 
*user_name,
  * otherwise \a variable. */
 static
 char const *
-muscle_percent_variable_update (char const *variable)
+muscle_percent_variable_update (char const *variable, location variable_loc)
 {
   typedef struct
   {
@@ -401,11 +401,18 @@ muscle_percent_variable_update (char const *variable)
       { "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
       { "namespace", "api.namespace", },
     };
+  char const *res = variable;
   int i;
-  for (i = 0; i < sizeof conversion / sizeof *conversion; ++i)
+  for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i)
     if (STREQ (conversion[i].obsolete, variable))
-      return conversion[i].updated;
-  return variable;
+      {
+        res = conversion[i].updated;
+        complain_at (variable_loc, Wdeprecated,
+                     _("deprecated %%define variable name: %s, use %s"),
+                     quote (variable), quote_n (1, res));
+        break;
+      }
+  return res;
 }
 
 void
@@ -419,7 +426,7 @@ muscle_percent_define_insert (char const *variable, 
location variable_loc,
   char const *how_name;
 
   /* Permit certain names with underscores for backward compatibility.  */
-  variable = muscle_percent_variable_update (variable);
+  variable = muscle_percent_variable_update (variable, variable_loc);
 
   name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
   loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
diff --git a/tests/input.at b/tests/input.at
index 1d0574f..056e578 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1180,7 +1180,8 @@ AT_DATA([[input.y]],
 start: ;
 ]])
 AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-21: invalid value for %define variable 'api.push-pull': 'neither'
+[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', 
use 'api.push-pull' [-Wdeprecated]
+input.y:1.9-21: invalid value for %define variable 'api.push-pull': 'neither'
 input.y:1.9-21: accepted value: 'pull'
 input.y:1.9-21: accepted value: 'push'
 input.y:1.9-21: accepted value: 'both'
@@ -1192,7 +1193,8 @@ AT_DATA([[input.y]],
 start: ;
 ]])
 AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-34: invalid value for %define Boolean variable 
'lr.keep-unreachable-states'
+[[input.y:1.9-34: warning: deprecated %define variable name: 
'lr.keep_unreachable_states', use 'lr.keep-unreachable-states' [-Wdeprecated]
+input.y:1.9-34: invalid value for %define Boolean variable 
'lr.keep-unreachable-states'
 ]])
 
 AT_DATA([[input.y]],
@@ -1202,7 +1204,8 @@ AT_DATA([[input.y]],
 start: ;
 ]])
 AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:2.9-21: %define variable 'api.namespace' redefined
+[[input.y:1.9-17: warning: deprecated %define variable name: 'namespace', use 
'api.namespace' [-Wdeprecated]
+input.y:2.9-21: %define variable 'api.namespace' redefined
 input.y:1.9-17: previous definition
 ]])
 
-- 
1.7.11.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]