X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/3ef9fa8f83316f7955babee666546feb5d9bdefc..df1ca1b0de2d99879f7b41e64d8bf285f163b1aa:/tests/conflicts.at diff --git a/tests/conflicts.at b/tests/conflicts.at index 81765aac..92e4ae87 100644 --- a/tests/conflicts.at +++ b/tests/conflicts.at @@ -17,6 +17,180 @@ AT_BANNER([[Conflicts.]]) +## ------------------------------ ## +## Useless associativity warning. ## +## ------------------------------ ## + +AT_SETUP([Useless associativity warning]) + +AT_DATA([[input.y]], +[[%token T +%left A B +%right C +%nonassoc D +%precedence E + +%% +e: T A T + | T B T + | T C T + | T D T + | T E T +; +]]) + +AT_BISON_CHECK([input.y], 0, [], +[[input.y:5.13: warning: useless precedence for E [-Wother] +input.y:2.7: warning: useless associativity for A [-Wother] +input.y:2.9: warning: useless associativity for B [-Wother] +input.y:3.8: warning: useless associativity for C [-Wother] +input.y:4.11: warning: useless associativity for D [-Wother] +]]) + +AT_CLEANUP + + +## ------------------------ ## +## Token declaration order. ## +## ------------------------ ## + +# This test checks that token are declared left to right when in a precedence +# statement. + +AT_SETUP([Token declaration order]) + +AT_BISON_OPTION_PUSHDEFS + +AT_DATA_GRAMMAR([[input.y]], +[[%code { + #include + ]AT_YYERROR_DECLARE[ + ]AT_YYLEX_DECLARE[ +} +%token A B C +%token D +%right E F G +%right H I +%right J +%left K +%left L M N +%nonassoc O P Q +%precedence R S T U +%precedence V W +%% +exp: A +%% +]AT_YYERROR_DEFINE[ +]AT_YYLEX_DEFINE[ +int main (void) +{ + assert (A < B); + assert (B < C); + assert (C < D); + assert (D < E); + assert (E < F); + assert (F < G); + assert (G < H); + assert (H < I); + assert (I < J); + assert (J < K); + assert (K < L); + assert (L < M); + assert (M < N); + assert (N < O); + assert (O < P); + assert (P < Q); + assert (Q < R); + assert (R < S); + assert (S < T); + assert (T < U); + assert (U < V); + assert (V < W); + return 0; +} +]]) + +AT_BISON_CHECK([-o input.c input.y], [], [], +[[input.y:24.13: warning: useless precedence for R [-Wother] +input.y:24.15: warning: useless precedence for S [-Wother] +input.y:24.17: warning: useless precedence for T [-Wother] +input.y:24.19: warning: useless precedence for U [-Wother] +input.y:25.13: warning: useless precedence for V [-Wother] +input.y:25.15: warning: useless precedence for W [-Wother] +input.y:18.8: warning: useless associativity for E [-Wother] +input.y:18.10: warning: useless associativity for F [-Wother] +input.y:18.12: warning: useless associativity for G [-Wother] +input.y:19.8: warning: useless associativity for H [-Wother] +input.y:19.10: warning: useless associativity for I [-Wother] +input.y:20.8: warning: useless associativity for J [-Wother] +input.y:21.8: warning: useless associativity for K [-Wother] +input.y:22.8: warning: useless associativity for L [-Wother] +input.y:22.10: warning: useless associativity for M [-Wother] +input.y:22.12: warning: useless associativity for N [-Wother] +input.y:23.11: warning: useless associativity for O [-Wother] +input.y:23.13: warning: useless associativity for P [-Wother] +input.y:23.15: warning: useless associativity for Q [-Wother] +]]) +AT_COMPILE([input]) + +AT_PARSER_CHECK([./input]) + +AT_BISON_OPTION_POPDEFS + +AT_CLEANUP + + +## ---------------------------- ## +## Useless precedence warning. ## +## ---------------------------- ## + +AT_SETUP([Useless precedence warning]) + +AT_DATA([[input.y]], +[[%token A B +%precedence Z +%left X +%precedence Y +%left W +%right V +%nonassoc U +%% +a: b + | a U b + | f +; +b: c + | b V c +; +c: d + | c W d +; +d: A + | d X d + | d Y A +; +f: B + | f Z B +; +]]) + +AT_BISON_CHECK([-fcaret -o input.c input.y], 0, [], +[[input.y:2.13: warning: useless precedence for Z [-Wother] + %precedence Z + ^ +input.y:5.7: warning: useless associativity for W [-Wother] + %left W + ^ +input.y:6.8: warning: useless associativity for V [-Wother] + %right V + ^ +input.y:7.11: warning: useless associativity for U [-Wother] + %nonassoc U + ^ +]]) + +AT_CLEANUP + ## ---------------- ## ## S/R in initial. ## @@ -1024,6 +1198,8 @@ e: e '+' e AT_BISON_CHECK([-o input.c input.y], 0, [], [[input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr] +input.y:1.7-9: warning: useless associativity for '+' [-Wother] +input.y:2.7-9: warning: useless associativity for '*' [-Wother] ]]) AT_CLEANUP