Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Small tweaks

  • Loading branch information...
commit 208297f3ac1d1670ff256478cbad872f72742b5d 1 parent aa82762
Nick Gasson authored

Showing 1 changed file with 9 additions and 5 deletions. Show diff stats Hide diff stats

  1. +9 5 src/cgen.c
14 src/cgen.c
@@ -1562,7 +1562,8 @@ static LLVMValueRef cgen_array_ref(tree_t t, cgen_ctx_t *ctx)
1562 1562 type_t type = tree_type(value);
1563 1563
1564 1564 LLVMValueRef idx = llvm_int32(0);
1565   - for (unsigned i = 0; i < tree_params(t); i++) {
  1565 + const int nparams = tree_params(t);
  1566 + for (int i = 0; i < nparams; i++) {
1566 1567 param_t p = tree_param(t, i);
1567 1568 assert(p.kind == P_POS);
1568 1569 LLVMValueRef offset = cgen_expr(p.value, ctx);
@@ -1658,7 +1659,8 @@ static LLVMValueRef *cgen_const_aggregate(tree_t t, cgen_ctx_t *ctx,
1658 1659 type_t type = tree_type(t);
1659 1660
1660 1661 *n_elems = 1;
1661   - for (unsigned i = dim; i < type_dims(type); i++) {
  1662 + const int ndims = type_dims(type);
  1663 + for (int i = dim; i < ndims; i++) {
1662 1664 range_t r = type_dim(type, i);
1663 1665
1664 1666 int64_t low, high;
@@ -1678,7 +1680,8 @@ static LLVMValueRef *cgen_const_aggregate(tree_t t, cgen_ctx_t *ctx,
1678 1680 for (unsigned i = 0; i < *n_elems; i++)
1679 1681 vals[i] = NULL;
1680 1682
1681   - for (unsigned i = 0; i < tree_assocs(t); i++) {
  1683 + const int nassocs = tree_assocs(t);
  1684 + for (int i = 0; i < nassocs; i++) {
1682 1685 assoc_t a = tree_assoc(t, i);
1683 1686
1684 1687 LLVMValueRef *sub;
@@ -1766,7 +1769,8 @@ static LLVMValueRef cgen_dyn_aggregate(tree_t t, cgen_ctx_t *ctx)
1766 1769 LLVMValueRef len = cgen_array_len(type, a);
1767 1770
1768 1771 LLVMValueRef def = NULL;
1769   - for (unsigned i = 0; i < tree_assocs(t); i++) {
  1772 + const int nassocs = tree_assocs(t);
  1773 + for (int i = 0; i < nassocs; i++) {
1770 1774 assoc_t a = tree_assoc(t, i);
1771 1775 if (a.kind == A_OTHERS) {
1772 1776 def = cgen_expr(a.value, ctx);
@@ -1790,7 +1794,7 @@ static LLVMValueRef cgen_dyn_aggregate(tree_t t, cgen_ctx_t *ctx)
1790 1794 LLVMPositionBuilderAtEnd(builder, body_bb);
1791 1795
1792 1796 LLVMValueRef what = def;
1793   - for (unsigned i = 0; i < tree_assocs(t); i++) {
  1797 + for (int i = 0; i < nassocs; i++) {
1794 1798 assoc_t a = tree_assoc(t, i);
1795 1799 switch (a.kind) {
1796 1800 case A_POS:

0 comments on commit 208297f

Please sign in to comment.
Something went wrong with that request. Please try again.