From 2d3227638381257499e33f524734cdc36825f830 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 7 Mar 2019 23:05:40 +0000 Subject: [PATCH] Added tests for errors in case of out-of-bounds EOF value. --- bootstrap/src/parse/lex_conf.cc | 4 ++-- src/parse/lex_conf.re | 2 +- test/eof/eof_06.c | 1 + test/eof/eof_06.re | 4 ++++ test/eof/eof_07.c | 1 + test/eof/eof_07.re | 5 +++++ test/eof/eof_08.8.c | 1 + test/eof/eof_08.8.re | 5 +++++ test/eof/eof_08.c | 1 + test/eof/eof_08.re | 5 +++++ test/eof/eof_08.u.c | 1 + test/eof/eof_08.u.re | 5 +++++ test/eof/eof_08.x.c | 1 + test/eof/eof_08.x.re | 5 +++++ 14 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 test/eof/eof_06.c create mode 100644 test/eof/eof_06.re create mode 100644 test/eof/eof_07.c create mode 100644 test/eof/eof_07.re create mode 100644 test/eof/eof_08.8.c create mode 100644 test/eof/eof_08.8.re create mode 100644 test/eof/eof_08.c create mode 100644 test/eof/eof_08.re create mode 100644 test/eof/eof_08.u.c create mode 100644 test/eof/eof_08.u.re create mode 100644 test/eof/eof_08.x.c create mode 100644 test/eof/eof_08.x.re diff --git a/bootstrap/src/parse/lex_conf.cc b/bootstrap/src/parse/lex_conf.cc index 6ce54f6d..48de5613 100644 --- a/bootstrap/src/parse/lex_conf.cc +++ b/bootstrap/src/parse/lex_conf.cc @@ -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 @@ -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(eof)); return; diff --git a/src/parse/lex_conf.re b/src/parse/lex_conf.re index 39a2fa08..c9385033 100644 --- a/src/parse/lex_conf.re +++ b/src/parse/lex_conf.re @@ -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(eof)); return; diff --git a/test/eof/eof_06.c b/test/eof/eof_06.c new file mode 100644 index 00000000..7c9a99b8 --- /dev/null +++ b/test/eof/eof_06.c @@ -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 index 00000000..97b4f952 --- /dev/null +++ b/test/eof/eof_06.re @@ -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 index 00000000..5b862c5f --- /dev/null +++ b/test/eof/eof_07.c @@ -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 index 00000000..be1a1c30 --- /dev/null +++ b/test/eof/eof_07.re @@ -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 index 00000000..e05539f1 --- /dev/null +++ b/test/eof/eof_08.8.c @@ -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 index 00000000..15051e82 --- /dev/null +++ b/test/eof/eof_08.8.re @@ -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 index 00000000..6ba36631 --- /dev/null +++ b/test/eof/eof_08.c @@ -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 index 00000000..4294c71f --- /dev/null +++ b/test/eof/eof_08.re @@ -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 index 00000000..e05539f1 --- /dev/null +++ b/test/eof/eof_08.u.c @@ -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 index 00000000..7569296d --- /dev/null +++ b/test/eof/eof_08.u.re @@ -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 index 00000000..e05539f1 --- /dev/null +++ b/test/eof/eof_08.x.c @@ -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 index 00000000..290428de --- /dev/null +++ b/test/eof/eof_08.x.re @@ -0,0 +1,5 @@ +/*!re2c + re2c:eof = 65536; + $ {} + * {} +*/ -- 2.49.0