Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2556 closed defect (fixed)

Support qualified component references in external function definitions

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc: c.schulze@…, Francesco Casella

Description

Currently the specification says that:
Spec 12.9:

"The only permissible kinds of expressions in the argument list are identifiers, scalar constants, and the function
size applied to an array and a constant dimension number. The annotations are used to pass additional information
to the compiler when necessary."

But some libraries use qualified component references i.e. crit.d
in the external function definition. We should support it but
issue a warning.

Change History (6)

comment:1 by Adrian Pop, 11 years ago

Owner: changed from somebody to Adrian Pop
Status: newaccepted

comment:2 by Adrian Pop, 11 years ago

The easiest way would be to just add dummy protected temp variables bound to the qualified variables.

comment:3 by Adrian Pop, 11 years ago

Cc: c.schulze@… Francesco Casella added

comment:4 by Martin Sjölund, 11 years ago

m:#351 suggests this might be supported. But it does not have any text on what the actual changes will be...

comment:5 by Per Östlund, 11 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r20049. No warning is issued since spec 3.3rev1 will allow this.

comment:6 by Martin Sjölund, 11 years ago

Note that the testcase does not consider records where the elements are not in lexical order (or contain arrays that need to be removed):

model QualifiedCrefArg
  record R
    Real y;
    Real x;
  end R;

  impure function f
    input R ri = R(x=1.0, y=2.0);
    output R r;
    external "C" r.y = f_ext(ri.x, ri.y, r) annotation(Library = "QualifiedCrefArg-f.o");
  end f;

  R r1 = f(R(x=3.0, y=2.0));
  R r2 = f();
end QualifiedCrefArg;

Gives results different from (with the original C-file):

model QualifiedCrefArg
  record R
    Real x;
    Real y;
  end R;
Note: See TracTickets for help on using tickets.