Changeset 13817


Ignore:
Timestamp:
Oct 23, 2019 12:27:17 PM (4 weeks ago)
Author:
Jonathan Kämpe
Message:

#5862 Fixed bug where empty array subscripts added during scalarization lead to c-compilation error.

Location:
branches/dev-jk-2597
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-jk-2597/CHANGELOG.txt

    r13719 r13817  
    11================= Unreleased ==================
     2# Fixed ; Minor ; Compiler ; #5862
     3Fixed bug where empty array subscripts added during scalarization lead to c-compilation error.
     4
    25# Feature ; Minor ; Compiler; #5837
    36Added a pre-compiled evaluator used for evaluating external functions
  • branches/dev-jk-2597/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenArrayTests.mo

    r12857 r13817  
    941941end RecordArray13;
    942942
     943model RecordArray14
     944    record R
     945        Real x = 1;
     946    end R;
     947   
     948    function f
     949        input Integer n;
     950        Real[n] xs;
     951        R[n] rs;
     952        output Real y;
     953    algorithm
     954        xs := rs.x;
     955        y := sum(xs);
     956        annotation(Inline=false);
     957    end f;
     958
     959    Real y = f(integer(time));
     960   
     961annotation(__JModelica(UnitTesting(tests={
     962    CCodeGenTestCase(
     963        name="RecordArray14",
     964        description="Test for bug in #5862",
     965        template="$C_functions$",
     966        generatedCode="
     967void func_CCodeGenArrayTests_RecordArray14_f_def0(jmi_real_t n_v, jmi_real_t* y_o) {
     968    JMI_DYNAMIC_INIT()
     969    JMI_ARR(HEAP, jmi_real_t, jmi_array_t, xs_a, -1, 1)
     970    JMI_ARR(HEAP, R_0_r, R_0_ra, rs_a, -1, 1)
     971    JMI_DEF(REA, tmp_1)
     972    JMI_DEF(REA, tmp_1_max)
     973    JMI_DEF(REA, y_v)
     974    JMI_DEF(REA, temp_1_v)
     975    jmi_real_t i1_0i;
     976    jmi_int_t i1_0ie;
     977    jmi_int_t i1_0in;
     978    jmi_real_t i1_1i;
     979    jmi_int_t i1_1ie;
     980    jmi_int_t i1_1in;
     981    jmi_real_t i1_2i;
     982    jmi_int_t i1_2ie;
     983    jmi_int_t i1_2in;
     984    JMI_ARRAY_INIT_1(HEAP, jmi_real_t, jmi_array_t, xs_a, n_v, 1, n_v)
     985    JMI_ARRAY_INIT_1(HEAP, R_0_r, R_0_ra, rs_a, n_v, 1, n_v)
     986    tmp_1_max = n_v + 1;
     987    for (tmp_1 = 1; tmp_1 < tmp_1_max; tmp_1++) {
     988    }
     989    i1_0in = 0;
     990    i1_0ie = floor((n_v) - (1));
     991    for (i1_0i = 1; i1_0in <= i1_0ie; i1_0i = 1 + (++i1_0in)) {
     992        jmi_array_rec_1(rs_a, i1_0i)->x = 1;
     993    }
     994    i1_1in = 0;
     995    i1_1ie = floor((n_v) - (1));
     996    for (i1_1i = 1; i1_1in <= i1_1ie; i1_1i = 1 + (++i1_1in)) {
     997        jmi_array_ref_1(xs_a, i1_1i) = jmi_array_rec_1(rs_a, i1_1i)->x;
     998    }
     999    temp_1_v = 0.0;
     1000    i1_2in = 0;
     1001    i1_2ie = floor((n_v) - (1));
     1002    for (i1_2i = 1; i1_2in <= i1_2ie; i1_2i = 1 + (++i1_2in)) {
     1003        temp_1_v = temp_1_v + jmi_array_val_1(xs_a, i1_2i);
     1004    }
     1005    y_v = temp_1_v;
     1006    JMI_RET(GEN, y_o, y_v)
     1007    JMI_DYNAMIC_FREE()
     1008    return;
     1009}
     1010
     1011jmi_real_t func_CCodeGenArrayTests_RecordArray14_f_exp0(jmi_real_t n_v) {
     1012    JMI_DEF(REA, y_v)
     1013    func_CCodeGenArrayTests_RecordArray14_f_def0(n_v, &y_v);
     1014    return y_v;
     1015}
     1016")})));
     1017end RecordArray14;
     1018
    9431019end CCodeGenArrayTests;
  • branches/dev-jk-2597/Compiler/ModelicaMiddleEnd/src/jastadd/scalarization/ScalarizeFunctions.jrag

    r12716 r13817  
    916916   
    917917    public void FAccessExp.addArrayUsesToIndexMap(Scalarizer s, FExp[] names) {
    918         if (!hasFArraySubscripts() && isArray())
     918        if (!hasFArraySubscripts() && myFV().isArray()) {
    919919            indexNames = names;
     920        }
    920921        super.addArrayUsesToIndexMap(s, names);
    921922    }
Note: See TracChangeset for help on using the changeset viewer.