diff options
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/basic-types/bug596637.c-expected | 14 | ||||
-rw-r--r-- | tests/control-flow/pre-post-increment-array-index.c-expected | 45 | ||||
-rw-r--r-- | tests/control-flow/pre-post-increment-array-index.vala | 14 | ||||
-rw-r--r-- | vala/valamemberaccess.vala | 2 |
5 files changed, 66 insertions, 10 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 9257e61ae..499d7f0d4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -311,6 +311,7 @@ TESTS = \ control-flow/nested-conditional.vala \ control-flow/null-conditional-bool.vala \ control-flow/pre-post-increment.vala \ + control-flow/pre-post-increment-array-index.vala \ control-flow/pre-post-increment-field.vala \ control-flow/pre-post-increment-local.vala \ control-flow/pre-post-increment-parameter.vala \ diff --git a/tests/basic-types/bug596637.c-expected b/tests/basic-types/bug596637.c-expected index 5d29263b7..2bdb6d02c 100644 --- a/tests/basic-types/bug596637.c-expected +++ b/tests/basic-types/bug596637.c-expected @@ -17,20 +17,16 @@ _vala_main (void) gint* _tmp0_; gint a_length1; gint _a_size_; - gint* _tmp1_; - gint _tmp1__length1; + gint _tmp1_; gint _tmp2_; - gint _tmp3_; _tmp0_ = g_new0 (gint, 1); a = _tmp0_; a_length1 = 1; _a_size_ = a_length1; - _tmp1_ = a; - _tmp1__length1 = a_length1; - _tmp2_ = _tmp1_[0]; - _tmp1_[0] = _tmp2_ + 1; - _tmp3_ = a[0]; - _vala_assert (_tmp3_ == 1, "a[0] == 1"); + _tmp1_ = a[0]; + a[0] = _tmp1_ + 1; + _tmp2_ = a[0]; + _vala_assert (_tmp2_ == 1, "a[0] == 1"); a = (g_free (a), NULL); } diff --git a/tests/control-flow/pre-post-increment-array-index.c-expected b/tests/control-flow/pre-post-increment-array-index.c-expected new file mode 100644 index 000000000..da5169eee --- /dev/null +++ b/tests/control-flow/pre-post-increment-array-index.c-expected @@ -0,0 +1,45 @@ +/* control_flow_pre_post_increment_array_index.c generated by valac, the Vala compiler + * generated from control_flow_pre_post_increment_array_index.vala, do not modify */ + +#include <glib.h> + +#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); +#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } +#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } +#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); + +static void _vala_main (void); + +static void +_vala_main (void) +{ + gchar foo[4] = {0}; + gint i = 0; + gint _tmp0_; + gint _tmp1_; + gint _tmp2_; + foo[4] = '\0'; + i = 0; + _tmp0_ = i; + i = _tmp0_ + 1; + foo[_tmp0_] = 'b'; + i = 0; + i = i + 1; + _tmp1_ = i; + foo[_tmp1_] = 'a'; + i = 2; + _tmp2_ = i; + i = _tmp2_ + 1; + foo[_tmp2_] = 'r'; + _vala_assert (i == 3, "i == 3"); + _vala_assert (g_strcmp0 ((const gchar*) foo, "bar") == 0, "(string) foo == \"bar\""); +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/control-flow/pre-post-increment-array-index.vala b/tests/control-flow/pre-post-increment-array-index.vala new file mode 100644 index 000000000..c8a08feca --- /dev/null +++ b/tests/control-flow/pre-post-increment-array-index.vala @@ -0,0 +1,14 @@ +void main () { + char foo[4]; + foo[4] = '\0'; + + var i = 0; + foo[i++] = 'b'; + i = 0; + foo[++i] = 'a'; + i = 2; + foo[i++] = 'r'; + + assert (i == 3); + assert ((string) foo == "bar"); +} diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index 3b91ece73..2b75adcc5 100644 --- a/vala/valamemberaccess.vala +++ b/vala/valamemberaccess.vala @@ -1200,7 +1200,7 @@ public class Vala.MemberAccess : Expression { bool is_tainted () { unowned CodeNode node = this; - if (node.parent_node is MemberAccess) { + if (node.parent_node is ElementAccess || node.parent_node is MemberAccess) { return false; } |