bison-patches
[Top][All Lists]
Advanced

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

parser: warn about hexadecimal token numbers in Yacc mode


From: Akim Demaille
Subject: parser: warn about hexadecimal token numbers in Yacc mode
Date: Fri, 14 Dec 2018 05:11:30 +0100

commit 953a95695a882ccc203e34cd6bf42585419b27e2
Author: Akim Demaille <address@hidden>
Date:   Thu Dec 13 18:22:43 2018 +0100

    parser: warn about hexadecimal token numbers 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 d3662690..07192f2b 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -846,6 +846,10 @@ static unsigned long
 scan_integer (char const *number, int base, location loc)
 {
   verify (INT_MAX < ULONG_MAX);
+  if (base == 16)
+    complain (&loc, Wyacc,
+              _("POSIX Yacc does not support hexadecimal literals"));
+
   unsigned long num = strtoul (number, NULL, base);
 
   if (INT_MAX < num)
diff --git a/tests/input.at b/tests/input.at
index 2b0b5573..2a20c404 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -147,6 +147,9 @@ AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [],
 [[input.y:1.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc]
  %nterm exp
  ^^^^^^
+input.y:2.12-15: warning: POSIX Yacc does not support hexadecimal literals 
[-Wyacc]
+ %token NUM 0x40 "number"
+            ^^^^
 ]])
 
 AT_CLEANUP




reply via email to

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