From bb4b189b9c94f66acfe0239b22f295d1314e173e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 14 Apr 2013 10:28:26 +0200 Subject: [PATCH] muscle: minor simplification which uncovers a missing warning * src/muscle-tab.c (muscle_percent_define_ensure): Discover the virtues of || to factor conditionals. * NEWS: As api.pure is no longer flagged as "used" by accident, we now have warnings for useless definitions. * tests/calc.at: So remove api.pure settings when running C++ tests, since C++ skeletons use a pure interface. --- NEWS | 2 ++ src/muscle-tab.c | 6 ++---- tests/calc.at | 19 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 5bc4d31e..e06cb77a 100644 --- a/NEWS +++ b/NEWS @@ -62,6 +62,8 @@ GNU Bison NEWS Changes in Bison 2.7 introduced a dependency on FILE and fprintf when locations are enabled. This is fixed. +*** Warnings about useless %pure-parser/%define api.pure are restored + ** Diagnostics reported by Bison Most of these features were contributed by Théophile Ranquet and Victor diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 5e2275e6..3f2793c5 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -541,10 +541,8 @@ muscle_percent_define_ensure (char const *variable, location loc, /* Don't complain is VARIABLE is already defined, but be sure to set its value to VAL. */ - if (!muscle_find_const (name)) - muscle_percent_define_insert (variable, loc, muscle_keyword, val, - MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); - if (muscle_percent_define_flag_if (variable) != value) + if (!muscle_find_const (name) + || muscle_percent_define_flag_if (variable) != value) muscle_percent_define_insert (variable, loc, muscle_keyword, val, MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } diff --git a/tests/calc.at b/tests/calc.at index eedfc897..00741f8e 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -683,13 +683,13 @@ AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %name-pr AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -AT_CHECK_CALC_LALR1_CC([%pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) @@ -716,10 +716,9 @@ AT_CHECK_CALC_GLR_CC([%defines %define parse.error verbose %name-prefix "calc" % AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%debug]) -AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc]) -AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -- 2.45.2