bison-patches
[Top][All Lists]
Advanced

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

parser: warn about string literals in Yacc mode


From: Akim Demaille
Subject: parser: warn about string literals in Yacc mode
Date: Fri, 14 Dec 2018 05:11:57 +0100

commit 465a47d46b0916387a5642cddb1fe7379e8e20e0
Author: Akim Demaille <address@hidden>
Date:   Thu Dec 13 18:26:24 2018 +0100

    parser: warn about string literals in Yacc mode
    
    * src/scan-gram.l (scan_integer): Warn.
    * tests/input.at (Yacc warnings on symbols): Check.

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);
   }
   <<EOF>>   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.




reply via email to

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