From 465a47d46b0916387a5642cddb1fe7379e8e20e0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 13 Dec 2018 18:26:24 +0100 Subject: [PATCH] parser: warn about string literals in Yacc mode * src/scan-gram.l (scan_integer): Warn. * tests/input.at (Yacc warnings on symbols): Check. --- src/scan-gram.l | 2 ++ tests/input.at | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/scan-gram.l b/src/scan-gram.l index 07192f2b..5fe0fc4e 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -521,6 +521,8 @@ eqopt ([[:space:]]*=)? STRING_FINISH; BEGIN INITIAL; loc->start = token_start; + complain (loc, Wyacc, + _("POSIX Yacc does not support string literals")); RETURN_VALUE (STRING, last_string); } <> unexpected_eof (token_start, "\""); diff --git a/tests/input.at b/tests/input.at index 2a20c404..47b584c6 100644 --- a/tests/input.at +++ b/tests/input.at @@ -150,6 +150,12 @@ AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [], input.y:2.12-15: warning: POSIX Yacc does not support hexadecimal literals [-Wyacc] %token NUM 0x40 "number" ^^^^ +input.y:2.17-24: warning: POSIX Yacc does not support string literals [-Wyacc] + %token NUM 0x40 "number" + ^^^^^^^^ +input.y:4.6-13: warning: POSIX Yacc does not support string literals [-Wyacc] + exp: "number"; + ^^^^^^^^ ]]) AT_CLEANUP @@ -1283,8 +1289,12 @@ AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([--yacc input.y], [1], [], [[input.y:1.1-5: error: POSIX Yacc does not support %code [-Werror=yacc] input.y:9.8-16: error: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Werror=yacc] +input.y:10.21-34: error: POSIX Yacc does not support string literals [-Werror=yacc] +input.y:12.23-38: error: POSIX Yacc does not support string literals [-Werror=yacc] input.y:13.1-5: error: POSIX Yacc does not support %code [-Werror=yacc] input.y:20.8-16: error: POSIX Yacc forbids dashes in symbol names: with-dash [-Werror=yacc] +input.y:22.15-28: error: POSIX Yacc does not support string literals [-Werror=yacc] +input.y:24.17-32: error: POSIX Yacc does not support string literals [-Werror=yacc] ]]) # Dashes are fine for GNU Bison.