[vala/0.36: 92/212] codegen: Enforce name-length >= 3 for structs using GType
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36: 92/212] codegen: Enforce name-length >= 3 for structs using GType
- Date: Sat, 14 Apr 2018 07:51:05 +0000 (UTC)
commit ec844b7d3eb9ed0197f1d149b90a7c2ab021df10
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Nov 19 15:29:55 2017 +0100
codegen: Enforce name-length >= 3 for structs using GType
https://bugzilla.gnome.org/show_bug.cgi?id=764041
codegen/valaccodestructmodule.vala | 6 ++++++
tests/Makefile.am | 1 +
tests/structs/bug764041.test | 10 ++++++++++
3 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 9774570..6548948 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -158,6 +158,12 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
push_context (new EmitContext (st));
push_line (st.source_reference);
+ if (get_ccode_has_type_id (st) && get_ccode_name (st).length < 3) {
+ st.error = true;
+ Report.error (st.source_reference, "Name `%s' is too short for struct using
GType".printf (get_ccode_name (st)));
+ return;
+ }
+
var old_instance_finalize_context = instance_finalize_context;
instance_finalize_context = new EmitContext ();
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 163c422..1e7f010 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -152,6 +152,7 @@ TESTS = \
structs/bug690380.vala \
structs/bug694140.vala \
structs/bug749952.vala \
+ structs/bug764041.test \
structs/bug775761.vala \
structs/bug777194.vala \
delegates/casting.vala \
diff --git a/tests/structs/bug764041.test b/tests/structs/bug764041.test
new file mode 100644
index 0000000..1911cda
--- /dev/null
+++ b/tests/structs/bug764041.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+struct N {
+ public int i;
+}
+
+void main() {
+ N n = { 42 };
+ Value v = n;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]