[gtk+/wip/otte/shader: 23/38] gsksldeclaration: Throw an error if a variable initializer doesn't match
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 23/38] gsksldeclaration: Throw an error if a variable initializer doesn't match
- Date: Thu, 28 Sep 2017 01:45:46 +0000 (UTC)
commit a945f548064d8d2d6cf0d6b5d8e000eb57530689
Author: Benjamin Otte <otte redhat com>
Date: Tue Sep 26 16:21:51 2017 +0200
gsksldeclaration: Throw an error if a variable initializer doesn't match
... the type of the declared variable and cannot be converted to it.
gsk/gskslnode.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskslnode.c b/gsk/gskslnode.c
index fd74ab0..fd10955 100644
--- a/gsk/gskslnode.c
+++ b/gsk/gskslnode.c
@@ -275,6 +275,14 @@ gsk_sl_node_parse_declaration (GskSlScope *scope,
{
gsk_sl_preprocessor_consume (stream, (GskSlNode *) declaration);
declaration->initial = gsk_sl_expression_parse_assignment (scope, stream);
+ if (!gsk_sl_type_can_convert (type, gsk_sl_expression_get_return_type (declaration->initial)))
+ {
+ gsk_sl_preprocessor_error (stream, "Cannot convert from initializer type %s to variable type %s",
+ gsk_sl_type_get_name (gsk_sl_expression_get_return_type
(declaration->initial)),
+ gsk_sl_type_get_name (type));
+ gsk_sl_node_unref ((GskSlNode *) declaration);
+ return NULL;
+ }
}
gsk_sl_scope_add_variable (scope, declaration->variable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]