[vala/0.54] parser: Reduce the source reference of main block method to its beginning
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.54] parser: Reduce the source reference of main block method to its beginning
- Date: Wed, 9 Feb 2022 13:02:36 +0000 (UTC)
commit c44eea7eee3d748469d08b7538d9608c62f1b618
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jan 18 14:33:15 2022 +0100
parser: Reduce the source reference of main block method to its beginning
The end contains broken information which lead to a crash while trying to
report this multi-line source reference.
tests/Makefile.am | 1 +
tests/parser/main-block-minimal.c-expected | 21 +++++++++++++++++++++
tests/parser/main-block-minimal.vala | 1 +
vala/valaparser.vala | 2 +-
4 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a7bf1ee45..dcc42df06 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -902,6 +902,7 @@ TESTS = \
parser/local-variable-array-type-invalid.test \
parser/lock-statement.vala \
parser/main-block.vala \
+ parser/main-block-minimal.vala \
parser/member-access-pointer.vala \
parser/member-initializer.vala \
parser/member-initializer-empty.vala \
diff --git a/tests/parser/main-block-minimal.c-expected b/tests/parser/main-block-minimal.c-expected
new file mode 100644
index 000000000..a8b8a94dc
--- /dev/null
+++ b/tests/parser/main-block-minimal.c-expected
@@ -0,0 +1,21 @@
+/* parser_main_block_minimal.c generated by valac, the Vala compiler
+ * generated from parser_main_block_minimal.vala, do not modify */
+
+#include <glib.h>
+
+static void _vala_main (void);
+
+static void
+_vala_main (void)
+{
+ g_print ("foo");
+}
+
+int
+main (int argc,
+ char ** argv)
+{
+ _vala_main ();
+ return 0;
+}
+
diff --git a/tests/parser/main-block-minimal.vala b/tests/parser/main-block-minimal.vala
new file mode 100644
index 000000000..d029e43fa
--- /dev/null
+++ b/tests/parser/main-block-minimal.vala
@@ -0,0 +1 @@
+print ("foo");
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 581092de2..5318bb265 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2517,7 +2517,7 @@ public class Vala.Parser : CodeVisitor {
void parse_main_block (Symbol parent) throws ParseError {
var begin = get_location ();
- var method = new Method ("main", new VoidType (), get_src (begin));
+ var method = new Method ("main", new VoidType (), new SourceReference (scanner.source_file,
begin, begin));
method.access = SymbolAccessibility.PUBLIC;
method.binding = MemberBinding.STATIC;
method.body = new Block (get_src (begin));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]