Changeset 13898


Ignore:
Timestamp:
Oct 29, 2019 1:28:58 PM (3 weeks ago)
Author:
molsson
Message:

#5843 Moved type checking of conditional attributes so that it is always done.

Location:
branches/dev-mo-2617/Compiler/ModelicaFrontEnd
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mo-2617/Compiler/ModelicaFrontEnd/src/jastadd/errorcheck/ErrorCheck.jrag

    r13103 r13898  
    852852                    getFArraySubscripts().collectErrors(checkType);
    853853                }
    854                 if (hasConditionalAttribute())  {
    855                     getConditionalAttribute().collectErrors(checkType);
     854                if (hasConditionalAttribute()) {
     855                    FExp cond = getConditionalAttribute();
     856                    cond.collectErrors(checkType);
     857                    if (!cond.type().isUnknown()) {
     858                        if (!cond.type().isScalar()) {
     859                            NON_SCALAR_CONDITIONAL_GUARD.invoke(this);
     860                        }
     861                        if (!cond.type().isBoolean()) {
     862                            NON_BOOLEAN_CONDITIONAL_GUARD.invoke(this);
     863                        }
     864                        if (!cond.variability().parameterOrLess()) {
     865                            NON_FIXED_CONDITIONAL_GUARD.invoke(this);
     866                        } else {
     867                            cond.markAsStructuralParameter(checkType);
     868                        }
     869                    }
    856870                }
    857871                if (!isDisabled() && hasInstModification()) {
  • branches/dev-mo-2617/Compiler/ModelicaFrontEnd/src/jastadd/errorcheck/TypeCheck.jrag

    r13396 r13898  
    200200                    "The guard expression of a conditional component should have parameter or constant variability");
    201201
     202    @Override
    202203    public void InstAssignable.typeCheck(ErrorCheckType checkType) {
    203204        FExp bexp = myBindingInstExp();
     
    262263                        typeCheckCell(expected, actual, bexp, unknownAllowed);
    263264                    }
    264                 }
    265             }
    266         }
    267        
    268         if (hasConditionalAttribute()) {
    269             FExp cond = getConditionalAttribute();
    270             if (!cond.type().isUnknown()) {
    271                 if (!cond.type().isScalar())
    272                     NON_SCALAR_CONDITIONAL_GUARD.invoke(this);
    273                 if (!cond.type().isBoolean())
    274                     NON_BOOLEAN_CONDITIONAL_GUARD.invoke(this);
    275                 if (!cond.variability().parameterOrLess()) {
    276                     NON_FIXED_CONDITIONAL_GUARD.invoke(this);
    277                 } else {
    278                     cond.markAsStructuralParameter(checkType);
    279265                }
    280266            }
  • branches/dev-mo-2617/Compiler/ModelicaFrontEnd/test/modelica/CheckTests.mo

    r12580 r13898  
    174174    parameter Boolean b = false;
    175175
    176     annotation(__JModelica(UnitTesting(tests={
    177         FlatteningTestCase(
    178             name="ConditionalError2",
    179             description="Check that inactive conditional components aren't error checked in compile mode",
    180             flatModel="
     176annotation(__JModelica(UnitTesting(tests={
     177    FlatteningTestCase(
     178        name="ConditionalError2",
     179        description="Check that inactive conditional components aren't error checked in compile mode",
     180        flatModel="
    181181fclass CheckTests.ConditionalError2
    182  parameter Boolean b = false /* false */;
     182 structural parameter Boolean b = false /* false */;
    183183end CheckTests.ConditionalError2;
    184184")})));
     
    203203    parameter Boolean b = false;
    204204
    205     annotation(__JModelica(UnitTesting(tests={
    206         FlatteningTestCase(
    207             name="ConditionalError3",
    208             description="Check that inactive conditional components aren't searched for used functions and enums when flattening in compile mode",
    209             flatModel="
     205annotation(__JModelica(UnitTesting(tests={
     206    FlatteningTestCase(
     207        name="ConditionalError3",
     208        description="Check that inactive conditional components aren't searched for used functions and enums when flattening in compile mode",
     209        flatModel="
    210210fclass CheckTests.ConditionalError3
    211  parameter Boolean b = false /* false */;
     211 structural parameter Boolean b = false /* false */;
    212212end CheckTests.ConditionalError3;
    213213")})));
  • branches/dev-mo-2617/Compiler/ModelicaFrontEnd/test/modelica/ConnectTests.mo

    r13456 r13898  
    31013101    connect(a.c, c);
    31023102
    3103     annotation(__JModelica(UnitTesting(tests={
    3104         FlatteningTestCase(
    3105             name="ConditionalNoErrTest6",
    3106             description="Ensure that components in conditionaly false components aren't error checked due to connections",
    3107             flatModel="
     3103annotation(__JModelica(UnitTesting(tests={
     3104    FlatteningTestCase(
     3105        name="ConditionalNoErrTest6",
     3106        description="Ensure that components in conditionaly false components aren't error checked due to connections",
     3107        flatModel="
    31083108fclass ConnectTests.ConditionalNoErrTest6
    3109  parameter Boolean on = false /* false */;
     3109 structural parameter Boolean on = false /* false */;
    31103110 Real c;
    31113111end ConnectTests.ConditionalNoErrTest6;
     
    31623162        flatModel="
    31633163fclass ConnectTests.ConditionalCompInConnector1
    3164  parameter Boolean c1.b = false /* false */;
     3164 structural parameter Boolean c1.b = false /* false */;
    31653165 potential Real c1.y;
    3166  parameter Boolean c2.b = false /* false */;
     3166 structural parameter Boolean c2.b = false /* false */;
    31673167 potential Real c2.y;
    31683168equation
  • branches/dev-mo-2617/Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo

    r13456 r13898  
    31473147            flatModel="
    31483148fclass NameTests.ConditionalComponentTest8
    3149  parameter Boolean b = false /* false */;
     3149 structural parameter Boolean b = false /* false */;
    31503150
    31513151end NameTests.ConditionalComponentTest8;
     
    31783178            flatModel="
    31793179fclass NameTests.ConditionalComponentTest9
    3180  parameter Boolean b = false /* false */;
     3180 structural parameter Boolean b = false /* false */;
    31813181
    31823182end NameTests.ConditionalComponentTest9;
     
    33803380")})));
    33813381end ConditionalComponentTest14;
     3382
     3383
     3384model ConditionalComponentTest15_Err
     3385    connector C
     3386        Real x;
     3387    end C;
     3388   
     3389    parameter Integer b[2] = {1,1};
     3390    C c if b;
     3391annotation(__JModelica(UnitTesting(tests={
     3392    ErrorTestCase(
     3393        description="Test of type checking of conditional composite component.",
     3394        errorMessage="
     33952 errors found:
     3396
     3397Error at line 7, column 5, in file 'Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo', NON_BOOLEAN_CONDITIONAL_GUARD:
     3398  The guard expression of a conditional component should be a boolean expression
     3399
     3400Error at line 7, column 5, in file 'Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo', NON_SCALAR_CONDITIONAL_GUARD:
     3401  The guard expression of a conditional component should be a scalar expression
     3402")})));
     3403end ConditionalComponentTest15_Err;
     3404
     3405
     3406model ConditionalComponentTest16
     3407    connector C
     3408        Real x;
     3409    end C;
     3410   
     3411    parameter Boolean b = false;
     3412    C c if b;
     3413annotation(__JModelica(UnitTesting(tests={
     3414    FlatteningTestCase(
     3415        description="Flattening conditional composite component",
     3416        flatModel="
     3417fclass NameTests.ConditionalComponentTest16
     3418 structural parameter Boolean b = false /* false */;
     3419end NameTests.ConditionalComponentTest16;
     3420")})));
     3421end ConditionalComponentTest16;
     3422
     3423
     3424model ConditionalComponentTest17
     3425    connector C
     3426        Real x;
     3427    end C;
     3428   
     3429    parameter Boolean b = true;
     3430    C c if b;
     3431annotation(__JModelica(UnitTesting(tests={
     3432    FlatteningTestCase(
     3433        description="Flattening conditional composite component",
     3434        flatModel="
     3435fclass NameTests.ConditionalComponentTest17
     3436 structural parameter Boolean b = true /* true */;
     3437 potential Real c.x;
     3438end NameTests.ConditionalComponentTest17;
     3439")})));
     3440end ConditionalComponentTest17;
     3441
     3442
    33823443
    33833444model AttributeDot1
  • branches/dev-mo-2617/Compiler/ModelicaFrontEnd/test/modelica/RedeclareTests.mo

    r13456 r13898  
    66196619    A a(use_b = false, redeclare C b);
    66206620
    6621     annotation(__JModelica(UnitTesting(tests={
    6622         FlatteningTestCase(
    6623             name="RedeclareConditional1",
    6624             description="Redeclaring inactive conditional as modification",
    6625             flatModel="
     6621annotation(__JModelica(UnitTesting(tests={
     6622    FlatteningTestCase(
     6623        name="Misc_RedeclareConditional1",
     6624        description="Redeclaring inactive conditional as modification",
     6625        flatModel="
    66266626fclass RedeclareTests.Misc.RedeclareConditional1
    6627  parameter Boolean a.use_b = false /* false */;
     6627 structural parameter Boolean a.use_b = false /* false */;
    66286628end RedeclareTests.Misc.RedeclareConditional1;
    66296629")})));
     
    66536653    D d;
    66546654
    6655     annotation(__JModelica(UnitTesting(tests={
    6656         FlatteningTestCase(
    6657             name="RedeclareConditional2",
    6658             description="Redeclaring inactive conditional as element",
    6659             flatModel="
     6655annotation(__JModelica(UnitTesting(tests={
     6656    FlatteningTestCase(
     6657        name="Misc_RedeclareConditional2",
     6658        description="Redeclaring inactive conditional as element",
     6659        flatModel="
    66606660fclass RedeclareTests.Misc.RedeclareConditional2
    6661  parameter Boolean d.use_b = false /* false */;
     6661 structural parameter Boolean d.use_b = false /* false */;
    66626662end RedeclareTests.Misc.RedeclareConditional2;
    66636663")})));
Note: See TracChangeset for help on using the changeset viewer.