Instead of
warning: deprecated %define variable name: 'namespace', use 'api.namespace' [-Wdeprecated]
display (in -fno-caret mode):
warning: deprecated directive: '%define namespace foo', use '%define api.namespace foo' [-Wdeprecated]
and (in -fcaret mode):
warning: deprecated directive, use '%define api.namespace toto' [-Wdeprecated]
%define namespace toto
^^^^^^^^^
This is in preparation of cases where not only the variable is
renamed, but the values are too:
warning: deprecated directive: '%define variant', use '%define api.value.type variant' [-Wdeprecated]
* src/muscle-tab.c (define_directive): New.
(muscle_percent_variable_update): Take the value as argument, and use it
in the diagnostics.
Loop with a pointer instead of an index.
* tests/input.at (%define backward compatibility): Adjust.
muscle_grow (key, "]]", "");
}
muscle_grow (key, "]]", "");
}
+static
+char *
+define_directive (char const *assignment, char const *value)
+{
+ char const *fmt = value && *value ? "%%define %s %s" : "%%define %s";
+ char *res = xmalloc (strlen (fmt) + strlen (assignment)
+ + (value ? strlen (value) : 0));
+ sprintf (res, fmt, assignment, value);
+ return res;
+}
+
/** If the \a variable name is obsolete, return the name to use,
* otherwise \a variable. */
static
char const *
/** If the \a variable name is obsolete, return the name to use,
* otherwise \a variable. */
static
char const *
-muscle_percent_variable_update (char const *variable, location variable_loc)
+muscle_percent_variable_update (char const *variable, location variable_loc,
+ char const **value)
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
{ "namespace", "api.namespace", },
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
{ "namespace", "api.namespace", },
};
char const *res = variable;
};
char const *res = variable;
- int i;
- for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i)
- if (STREQ (conversion[i].obsolete, variable))
+ conversion_type const *c;
+ for (c = conversion; c->obsolete; ++c)
+ if (STREQ (c->obsolete, variable))
- res = conversion[i].updated;
- complain (&variable_loc, Wdeprecated,
- _("deprecated %%define variable name: %s, use %s"),
- quote (variable), quote_n (1, res));
+ char *old = define_directive (c->obsolete, *value);
+ char *upd = define_directive (c->updated, *value);
+ deprecated_directive (&variable_loc, old, upd);
+ free (old);
+ free (upd);
+ res = c->updated;
muscle_percent_define_how how)
{
/* Backward compatibility. */
muscle_percent_define_how how)
{
/* Backward compatibility. */
- char const *variable = muscle_percent_variable_update (var, variable_loc);
+ char *variable = muscle_percent_variable_update (var, variable_loc, &value);
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
char const *syncline_name =
char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
char const *syncline_name =
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', use 'api.push-pull' [-Wdeprecated]
+[[input.y:1.9-21: warning: deprecated directive: '%define api.push_pull neither', use '%define api.push-pull neither' [-Wdeprecated]
input.y:1.9-21: error: 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: error: 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'
]])
AT_BISON_CHECK([[-fcaret input.y]], [1], [],
]])
AT_BISON_CHECK([[-fcaret input.y]], [1], [],
-[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', use 'api.push-pull' [-Wdeprecated]
+[[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull neither' [-Wdeprecated]
%define api.push_pull "neither"
^^^^^^^^^^^^^
input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
%define api.push_pull "neither"
^^^^^^^^^^^^^
input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-state' [-Wdeprecated]
+[[input.y:1.9-34: warning: deprecated directive: '%define lr.keep_unreachable_states maybe', use '%define lr.keep-unreachable-state maybe' [-Wdeprecated]
input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state'
]])
input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state'
]])
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-17: warning: deprecated %define variable name: 'namespace', use 'api.namespace' [-Wdeprecated]
+[[input.y:1.9-17: warning: deprecated directive: '%define namespace foo', use '%define api.namespace foo' [-Wdeprecated]
input.y:2.9-21: error: %define variable 'api.namespace' redefined
input.y:1.9-17: previous definition
]])
input.y:2.9-21: error: %define variable 'api.namespace' redefined
input.y:1.9-17: previous definition
]])