]> granicus.if.org Git - re2c/commitdiff
Added tests for errors in case of out-of-bounds EOF value.
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 7 Mar 2019 23:05:40 +0000 (23:05 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 7 Mar 2019 23:09:02 +0000 (23:09 +0000)
14 files changed:
bootstrap/src/parse/lex_conf.cc
src/parse/lex_conf.re
test/eof/eof_06.c [new file with mode: 0644]
test/eof/eof_06.re [new file with mode: 0644]
test/eof/eof_07.c [new file with mode: 0644]
test/eof/eof_07.re [new file with mode: 0644]
test/eof/eof_08.8.c [new file with mode: 0644]
test/eof/eof_08.8.re [new file with mode: 0644]
test/eof/eof_08.c [new file with mode: 0644]
test/eof/eof_08.re [new file with mode: 0644]
test/eof/eof_08.u.c [new file with mode: 0644]
test/eof/eof_08.u.re [new file with mode: 0644]
test/eof/eof_08.x.c [new file with mode: 0644]
test/eof/eof_08.x.re [new file with mode: 0644]

index 6ce54f6d1142a9a32e95591411fbef9063ca5905..48de5613f3457a232fcaf472c1d6d31234b532dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 1.1.1 on Tue Feb 12 22:50:47 2019 */
+/* Generated by re2c 1.1.1 on Thu Mar  7 22:57:34 2019 */
 #line 1 "../src/parse/lex_conf.re"
 #include "src/util/c99_stdint.h"
 #include <string>
@@ -231,7 +231,7 @@ yy29:
        {
         const int32_t eof = lex_conf_number();
         if (eof < 0) {
-            msg.fatal(cur_loc(), "eof cannot have negative value");
+            msg.fatal(cur_loc(), "EOF symbol cannot have negative value");
         }
         opts.set_eof(static_cast<uint32_t>(eof));
         return;
index 39a2fa0882980461e0a48a2a1b9f6c39c8f8c392..c9385033dd9cd58868822310f12642d7d3badcd6 100644 (file)
@@ -71,7 +71,7 @@ void Scanner::lex_conf(Opt &opts)
     "eof" {
         const int32_t eof = lex_conf_number();
         if (eof < 0) {
-            msg.fatal(cur_loc(), "eof cannot have negative value");
+            msg.fatal(cur_loc(), "EOF symbol cannot have negative value");
         }
         opts.set_eof(static_cast<uint32_t>(eof));
         return;
diff --git a/test/eof/eof_06.c b/test/eof/eof_06.c
new file mode 100644 (file)
index 0000000..7c9a99b
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: 're2c:eof' configuration is set, but no EOF rule found
diff --git a/test/eof/eof_06.re b/test/eof/eof_06.re
new file mode 100644 (file)
index 0000000..97b4f95
--- /dev/null
@@ -0,0 +1,4 @@
+/*!re2c
+    re2c:eof = 0;
+    * {}
+*/
diff --git a/test/eof/eof_07.c b/test/eof/eof_07.c
new file mode 100644 (file)
index 0000000..5b862c5
--- /dev/null
@@ -0,0 +1 @@
+eof/eof_07.re:2:18: error: EOF symbol cannot have negative value
diff --git a/test/eof/eof_07.re b/test/eof/eof_07.re
new file mode 100644 (file)
index 0000000..be1a1c3
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+    re2c:eof = -1;
+    $ {}
+    * {}
+*/
diff --git a/test/eof/eof_08.8.c b/test/eof/eof_08.8.c
new file mode 100644 (file)
index 0000000..e05539f
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: EOF exceeds maximum code unit value for given encoding
diff --git a/test/eof/eof_08.8.re b/test/eof/eof_08.8.re
new file mode 100644 (file)
index 0000000..15051e8
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+    re2c:eof = 256;
+    $ {}
+    * {}
+*/
diff --git a/test/eof/eof_08.c b/test/eof/eof_08.c
new file mode 100644 (file)
index 0000000..6ba3663
--- /dev/null
@@ -0,0 +1 @@
+eof/eof_08.re:2:25: error: configuration value overflow
diff --git a/test/eof/eof_08.re b/test/eof/eof_08.re
new file mode 100644 (file)
index 0000000..4294c71
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+    re2c:eof = 9999999999;
+    $ {}
+    * {}
+*/
diff --git a/test/eof/eof_08.u.c b/test/eof/eof_08.u.c
new file mode 100644 (file)
index 0000000..e05539f
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: EOF exceeds maximum code unit value for given encoding
diff --git a/test/eof/eof_08.u.re b/test/eof/eof_08.u.re
new file mode 100644 (file)
index 0000000..7569296
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+    re2c:eof = 1114112;
+    $ {}
+    * {}
+*/
diff --git a/test/eof/eof_08.x.c b/test/eof/eof_08.x.c
new file mode 100644 (file)
index 0000000..e05539f
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: EOF exceeds maximum code unit value for given encoding
diff --git a/test/eof/eof_08.x.re b/test/eof/eof_08.x.re
new file mode 100644 (file)
index 0000000..290428d
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+    re2c:eof = 65536;
+    $ {}
+    * {}
+*/