Bug 531237 - [codegen] Incorrect field descriptors for static, global and define attributes
Summary: [codegen] Incorrect field descriptors for static, global and define attributes
Status: NEW
Alias: None
Product: Papyrus-rt
Classification: Modeling
Component: codegen (show other bugs)
Version: 1.0.0   Edit
Hardware: All All
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-15 16:56 EST by Ernesto Posse CLA
Modified: 2018-02-16 08:23 EST (History)
1 user (show)

See Also:


Attachments
Sample model (2.67 KB, application/zip)
2018-02-15 16:56 EST, Ernesto Posse CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ernesto Posse CLA 2018-02-15 16:56:07 EST
Created attachment 272692 [details]
Sample model

When an attribute in a (passive) class is marked as static, or when it has the AttributeProperties stereotype with kind=="Global" or kind=="Define", or AttributeProperties.type is not null, then the generated code has incorrect type descriptors and compilation will fail. See the attached model.

In the sample model there is a class Class1 with five attributes a1, a2, a3, a4 and a5. a1 is a normal attribute. a2 is static. a3 has kind=="Global". a4 has kind=="Define" and a5 has a non-null type in the stereotype.

The generated code in Class1.cc is

[code]
float Class1::a2;
const UMLRTObject_field Class1::fields[] = 
{
    {
        "a1",
        &UMLRTType_float,
        offsetof( Class1, a1 ),
        1,
        0
    },
    {
        "a3",
        &UMLRTType_float,
        offsetof( Class1, a3 ),
        1,
        0
    },
    {
        "a4",
        &UMLRTType_float,
        offsetof( Class1, a4 ),
        1,
        0
    }
};

float a3;
[/code]

A descriptor for a2 is missing from fields. The declaration of a3 is done after fields and it is global so the offset expression cannot be resolved. a4 is not declared anywhere, and no descriptor is generated for a5.

All these will cause compilation errors.