Changes in / [30a1f0c:56a8eb8]


Ignore:
Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r30a1f0c r56a8eb8  
    296296        newnode->type->array.dimension = size;
    297297        newnode->type->array.isStatic = isStatic;
    298         newnode->type->array.isVarLen = size && !size->isExpressionType<ast::ConstantExpr *>();
     298        if ( newnode->type->array.dimension == nullptr || newnode->type->array.dimension->isExpressionType<ast::ConstantExpr *>() ) {
     299                newnode->type->array.isVarLen = false;
     300        } else {
     301                newnode->type->array.isVarLen = true;
     302        } // if
    299303        return newnode->addQualifiers( qualifiers );
    300304} // DeclarationNode::newArray
  • src/Parser/TypeData.cc

    r30a1f0c r56a8eb8  
    12911291
    12921292
    1293 static ast::Type * buildDefaultType( const TypeData * td ) {
    1294         return ( td ) ? typebuild( td ) : new ast::BasicType( ast::BasicType::SignedInt );
    1295 } // buildDefaultType
    1296 
    1297 
    12981293ast::PointerType * buildPointer( const TypeData * td ) {
    1299         return new ast::PointerType(
    1300                 buildDefaultType( td->base ),
    1301                 buildQualifiers( td )
    1302         );
     1294        ast::PointerType * pt;
     1295        if ( td->base ) {
     1296                pt = new ast::PointerType(
     1297                        typebuild( td->base ),
     1298                        buildQualifiers( td )
     1299                );
     1300        } else {
     1301                pt = new ast::PointerType(
     1302                        new ast::BasicType( ast::BasicType::SignedInt ),
     1303                        buildQualifiers( td )
     1304                );
     1305        } // if
     1306        return pt;
    13031307} // buildPointer
    13041308
    13051309
    13061310ast::ArrayType * buildArray( const TypeData * td ) {
    1307         return new ast::ArrayType(
    1308                 buildDefaultType( td->base ),
    1309                 maybeBuild( td->array.dimension ),
    1310                 td->array.isVarLen ? ast::VariableLen : ast::FixedLen,
    1311                 td->array.isStatic ? ast::StaticDim : ast::DynamicDim,
    1312                 buildQualifiers( td )
    1313         );
     1311        ast::ArrayType * at;
     1312        if ( td->base ) {
     1313                at = new ast::ArrayType(
     1314                        typebuild( td->base ),
     1315                        maybeBuild( td->array.dimension ),
     1316                        td->array.isVarLen ? ast::VariableLen : ast::FixedLen,
     1317                        td->array.isStatic ? ast::StaticDim : ast::DynamicDim,
     1318                        buildQualifiers( td )
     1319                );
     1320        } else {
     1321                at = new ast::ArrayType(
     1322                        new ast::BasicType( ast::BasicType::SignedInt ),
     1323                        maybeBuild( td->array.dimension ),
     1324                        td->array.isVarLen ? ast::VariableLen : ast::FixedLen,
     1325                        td->array.isStatic ? ast::StaticDim : ast::DynamicDim,
     1326                        buildQualifiers( td )
     1327                );
     1328        } // if
     1329        return at;
    13141330} // buildArray
    13151331
    13161332
    13171333ast::ReferenceType * buildReference( const TypeData * td ) {
    1318         return new ast::ReferenceType(
    1319                 buildDefaultType( td->base ),
    1320                 buildQualifiers( td )
    1321         );
     1334        ast::ReferenceType * rt;
     1335        if ( td->base ) {
     1336                rt = new ast::ReferenceType(
     1337                        typebuild( td->base ),
     1338                        buildQualifiers( td )
     1339                );
     1340        } else {
     1341                rt = new ast::ReferenceType(
     1342                        new ast::BasicType( ast::BasicType::SignedInt ),
     1343                        buildQualifiers( td )
     1344                );
     1345        } // if
     1346        return rt;
    13221347} // buildReference
    13231348
Note: See TracChangeset for help on using the changeset viewer.