Changeset 1fbab5a for src/Parser


Ignore:
Timestamp:
Mar 16, 2017, 4:50:08 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
395fc37, 64ac636, ef42b143
Parents:
2f26687a (diff), d6d747d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 10:19:38 2017
    13 // Update Count     : 964
     12// Last Modified On : Thu Mar 16 09:10:57 2017
     13// Update Count     : 1007
    1414//
    1515
     
    3333
    3434// These must remain in the same order as the corresponding DeclarationNode enumerations.
    35 const char * DeclarationNode::storageClassNames[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" };
    36 const char * DeclarationNode::funcSpecifierNames[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };
    37 const char * DeclarationNode::typeQualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };
    3835const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" };
    3936const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" };
     
    116113}
    117114
    118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) {
    119         if ( storageClasses.val != 0 ) {                                        // storage classes ?
    120                 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) {
    121                         if ( storageClasses[i] ) {
    122                                 output << DeclarationNode::storageClassNames[i] << ' ';
    123                         } // if
    124                 } // for
    125         } // if
    126 } // print_StorageClass
    127 
    128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) {
    129         if ( funcSpec.val != 0 ) {                                                      // function specifiers ?
    130                 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) {
    131                         if ( funcSpec[i] ) {
    132                                 output << DeclarationNode::funcSpecifierNames[i] << ' ';
    133                         } // if
    134                 } // for
    135         } // if
    136 } // print_FuncSpec
    137 
    138115void DeclarationNode::print( std::ostream &os, int indent ) const {
    139116        os << string( indent, ' ' );
     
    148125        } // if
    149126
    150         print_StorageClass( os, storageClasses );
    151         print_FuncSpec( os, funcSpecs );
     127        storageClasses.print( os );
     128        funcSpecs.print( os );
    152129
    153130        if ( type ) {
     
    202179
    203180
    204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) {
     181DeclarationNode * DeclarationNode::newStorageClass( Type::StorageClasses sc ) {
    205182        DeclarationNode * newnode = new DeclarationNode;
    206183        newnode->storageClasses = sc;
     
    208185} // DeclarationNode::newStorageClass
    209186
    210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) {
     187DeclarationNode * DeclarationNode::newFuncSpecifier( Type::FuncSpecifiers fs ) {
    211188        DeclarationNode * newnode = new DeclarationNode;
    212189        newnode->funcSpecs = fs;
     
    214191} // DeclarationNode::newFuncSpecifier
    215192
    216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) {
     193DeclarationNode * DeclarationNode::newTypeQualifier( Type::Qualifiers tq ) {
    217194        DeclarationNode * newnode = new DeclarationNode;
    218195        newnode->type = new TypeData();
    219         newnode->type->typeQualifiers[ tq ] = true;
     196        newnode->type->qualifiers = tq;
    220197        return newnode;
    221198} // DeclarationNode::newQualifier
     
    457434
    458435void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) {
    459         const TypeData::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization
    460 
    461         if ( (qsrc & qdst).any() ) {                                            // duplicates ?
    462                 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates
     436        const Type::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization
     437
     438        if ( (qsrc.val & qdst.val) != 0 ) {                                     // duplicates ?
     439                for ( unsigned int i = 0; i < Type::NumTypeQualifier; i += 1 ) { // find duplicates
    463440                        if ( qsrc[i] && qdst[i] ) {
    464                                 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] );
     441                                appendError( error, string( "duplicate " ) + Type::Qualifiers::Names[i] );
    465442                        } // if
    466443                } // for
     
    469446
    470447void DeclarationNode::checkSpecifiers( DeclarationNode * src ) {
    471         if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) {                // duplicates ?
    472                 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates
     448        if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) {      // duplicates ?
     449                for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates
    473450                        if ( funcSpecs[i] && src->funcSpecs[i] ) {
    474                                 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] );
     451                                appendError( error, string( "duplicate " ) + Type::FuncSpecifiers::Names[i] );
    475452                        } // if
    476453                } // for
    477454        } // if
    478455
    479         if ( storageClasses.val != 0 && src->storageClasses.val != 0 ) { // any reason to check ?
     456        if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ?
    480457                if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ?
    481                         for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates
     458                        for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates
    482459                                if ( storageClasses[i] && src->storageClasses[i] ) {
    483                                         appendError( error, string( "duplicate " ) + storageClassNames[i] );
     460                                        appendError( error, string( "duplicate " ) + Type::StorageClasses::Names[i] );
    484461                                } // if
    485462                        } // for
    486463                        // src is the new item being added and has a single bit
    487464                } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ?
    488                         appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] +
    489                                                  " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] );
     465                        appendError( error, string( "conflicting " ) + Type::StorageClasses::Names[ffs( storageClasses.val ) - 1] +
     466                                                 " & " + Type::StorageClasses::Names[ffs( src->storageClasses.val ) - 1] );
    490467                        src->storageClasses.val = 0;                            // FIX to preserve invariant of one basic storage specifier
    491468                } // if
     
    496473
    497474DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) {
    498         funcSpecs.val = funcSpecs.val | q->funcSpecs.val;
    499         storageClasses.val = storageClasses.val | q->storageClasses.val;
     475        funcSpecs.val |= q->funcSpecs.val;
     476        storageClasses.val |= q->storageClasses.val;
    500477
    501478        for ( Attribute *attr: reverseIterate( q->attributes ) ) {
     
    520497                src = nullptr;
    521498        } else {
    522                 dst->typeQualifiers |= src->typeQualifiers;
     499                dst->qualifiers += src->qualifiers;
    523500        } // if
    524501} // addQualifiersToType
     
    578555                switch ( dst->kind ) {
    579556                  case TypeData::Unknown:
    580                         src->typeQualifiers |= dst->typeQualifiers;
     557                        src->qualifiers += dst->qualifiers;
    581558                        dst = src;
    582559                        src = nullptr;
    583560                        break;
    584561                  case TypeData::Basic:
    585                         dst->typeQualifiers |= src->typeQualifiers;
     562                        dst->qualifiers += src->qualifiers;
    586563                        if ( src->kind != TypeData::Unknown ) {
    587564                                assert( src->kind == TypeData::Basic );
     
    619596                                        dst->base->aggInst.params = maybeClone( src->aggregate.actuals );
    620597                                } // if
    621                                 dst->base->typeQualifiers |= src->typeQualifiers;
     598                                dst->base->qualifiers += src->qualifiers;
    622599                                src = nullptr;
    623600                                break;
     
    651628                                                type->aggInst.hoistType = o->type->enumeration.body;
    652629                                        } // if
    653                                         type->typeQualifiers |= o->type->typeQualifiers;
     630                                        type->qualifiers += o->type->qualifiers;
    654631                                } else {
    655632                                        type = o->type;
     
    807784                                        p->type->base->aggInst.params = maybeClone( type->aggregate.actuals );
    808785                                } // if
    809                                 p->type->base->typeQualifiers |= type->typeQualifiers;
     786                                p->type->base->qualifiers += type->qualifiers;
    810787                                break;
    811788
     
    832809
    833810DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) {
    834         if ( a ) {
    835                 assert( a->type->kind == TypeData::Array );
    836                 TypeData * lastArray = findLast( a->type );
    837                 if ( type ) {
    838                         switch ( type->kind ) {
    839                           case TypeData::Aggregate:
    840                           case TypeData::Enum:
    841                                 lastArray->base = new TypeData( TypeData::AggregateInst );
    842                                 lastArray->base->aggInst.aggregate = type;
    843                                 if ( type->kind == TypeData::Aggregate ) {
    844                                         lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals );
    845                                 } // if
    846                                 lastArray->base->typeQualifiers |= type->typeQualifiers;
    847                                 break;
    848                           default:
    849                                 lastArray->base = type;
    850                         } // switch
    851                         type = nullptr;
    852                 } // if
    853                 delete this;
    854                 return a;
    855         } else {
    856                 return this;
    857         } // if
     811  if ( ! a ) return this;
     812        assert( a->type->kind == TypeData::Array );
     813        TypeData * lastArray = findLast( a->type );
     814        if ( type ) {
     815                switch ( type->kind ) {
     816                  case TypeData::Aggregate:
     817                  case TypeData::Enum:
     818                        lastArray->base = new TypeData( TypeData::AggregateInst );
     819                        lastArray->base->aggInst.aggregate = type;
     820                        if ( type->kind == TypeData::Aggregate ) {
     821                                lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals );
     822                        } // if
     823                        lastArray->base->qualifiers += type->qualifiers;
     824                        break;
     825                  default:
     826                        lastArray->base = type;
     827                } // switch
     828                type = nullptr;
     829        } // if
     830        delete this;
     831        return a;
    858832}
    859833
     
    994968                                } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    995969                                        StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
    996                                         auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );
     970                                        auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    997971                                        obj->location = cur->location;
    998972                                        * out++ = obj;
     
    1000974                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    1001975                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
    1002                                         auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );
     976                                        auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    1003977                                        obj->location = cur->location;
    1004978                                        * out++ = obj;
     
    10471021                assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." );
    10481022                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1049                 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );
     1023                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );
    10501024                buildList( variable.assertions, ret->get_assertions() );
    10511025                return ret;
     
    10581032                //    inline _Noreturn int g( int i );  // allowed
    10591033                //    inline _Noreturn int i;                   // disallowed
    1060                 if ( type->kind != TypeData::Function && funcSpecs.val != 0 ) {
     1034                if ( type->kind != TypeData::Function && funcSpecs.any() ) {
    10611035                        throw SemanticError( "invalid function specifier for ", this );
    10621036                } // if
     
    10681042        //    inlne _Noreturn struct S { ... };         // disallowed
    10691043        //    inlne _Noreturn enum   E { ... };         // disallowed
    1070         if ( funcSpecs.val != 0 ) {
     1044        if ( funcSpecs.any() ) {
    10711045                throw SemanticError( "invalid function specifier for ", this );
    10721046        } // if
  • src/Parser/ParseNode.h

    r2f26687a r1fbab5a  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 11:05:05 2017
    13 // Update Count     : 752
     12// Last Modified On : Thu Mar 16 08:32:43 2017
     13// Update Count     : 776
    1414//
    1515
     
    1919#include <string>
    2020#include <list>
    21 #include <bitset>
    2221#include <iterator>
    2322#include <memory>
     
    202201class DeclarationNode : public ParseNode {
    203202  public:
    204         // These must remain in the same order as the corresponding DeclarationNode names.
    205 
    206         enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 };
    207         union StorageClasses {
    208                 unsigned int val;
    209                 struct {
    210                         bool is_extern : 1;
    211                         bool is_static : 1;
    212                         bool is_auto : 1;
    213                         bool is_register : 1;
    214                         bool is_threadlocal : 1;
    215                 };
    216                 StorageClasses() : val( 0 ) {}
    217                 StorageClasses( unsigned int val ) : val( val ) {}
    218                 bool operator[]( unsigned int i ) const { return val & (1 << i); }
    219         }; // StorageClasses
    220 
    221         enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 };
    222         union FuncSpecifiers {
    223                 unsigned int val;
    224                 struct {
    225                         bool is_inline : 1;
    226                         bool is_noreturn : 1;
    227                         bool is_fortran : 1;
    228                 };
    229                 FuncSpecifiers() : val( 0 ) {}
    230                 FuncSpecifiers( unsigned int val ) : val( val ) {}
    231                 bool operator[]( unsigned int i ) const { return val & (1 << i); }
    232         }; // FuncSpecifiers
    233 
    234         enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier };
    235203        enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType };
    236204        enum ComplexType { Complex, Imaginary, NoComplexType };
     
    241209        enum BuiltinType { Valist, Zero, One, NoBuiltinType };
    242210
    243         static const char * storageClassNames[];
    244         static const char * funcSpecifierNames[];
    245         static const char * typeQualifierNames[];
    246211        static const char * basicTypeNames[];
    247212        static const char * complexTypeNames[];
     
    252217        static const char * builtinTypeNames[];
    253218
    254         static DeclarationNode * newStorageClass( StorageClasses );
    255         static DeclarationNode * newFuncSpecifier( FuncSpecifiers );
    256         static DeclarationNode * newTypeQualifier( TypeQualifier );
     219        static DeclarationNode * newStorageClass( Type::StorageClasses );
     220        static DeclarationNode * newFuncSpecifier( Type::FuncSpecifiers );
     221        static DeclarationNode * newTypeQualifier( Type::Qualifiers );
    257222        static DeclarationNode * newBasicType( BasicType );
    258223        static DeclarationNode * newComplexType( ComplexType );
     
    350315        TypeData * type;
    351316
    352         StorageClasses storageClasses;
    353         static void print_StorageClass( std::ostream & output, StorageClasses storageClasses );
    354 
    355         FuncSpecifiers funcSpecs;
    356         static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs );
     317        Type::FuncSpecifiers funcSpecs;
     318        Type::StorageClasses storageClasses;
    357319
    358320        ExpressionNode * bitfieldWidth;
  • src/Parser/TypeData.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 08:08:21 2017
    13 // Update Count     : 538
     12// Last Modified On : Thu Mar 16 08:32:42 2017
     13// Update Count     : 559
    1414//
    1515
     
    2626using namespace std;
    2727
    28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {
     28TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ {
    2929        switch ( kind ) {
    3030          case Unknown:
     
    5050                function.newStyle = false;
    5151                break;
     52                // Enum is an Aggregate, so both structures are initialized together.
     53          case Enum:
     54                // enumeration = new Enumeration_t;
     55                enumeration.name = nullptr;
     56                enumeration.constants = nullptr;
     57                enumeration.body = false;
    5258          case Aggregate:
    5359                // aggregate = new Aggregate_t;
     
    6470                aggInst.hoistType = false;;
    6571                break;
    66           case Enum:
    67                 // enumeration = new Enumeration_t;
    68                 enumeration.name = nullptr;
    69                 enumeration.constants = nullptr;
    70                 enumeration.body = false;
    71                 break;
    7272          case Symbolic:
    7373          case SymbolicInst:
     
    157157TypeData * TypeData::clone() const {
    158158        TypeData * newtype = new TypeData( kind );
    159         newtype->typeQualifiers = typeQualifiers;
     159        newtype->qualifiers = qualifiers;
    160160        newtype->base = maybeClone( base );
    161161        newtype->forall = maybeClone( forall );
     
    226226
    227227void TypeData::print( ostream &os, int indent ) const {
    228         for ( int i = 0; i < DeclarationNode::NoTypeQualifier; i += 1 ) {
    229                 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' ';
     228        for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) {
     229                if ( qualifiers[i] ) os << Type::Qualifiers::Names[ i ] << ' ';
    230230        } // for
    231231
     
    398398                        // add dtor:  void ^?{}(T *)
    399399                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );
    400                         dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    401                         td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );
     400                        dtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     401                        td->get_assertions().push_front( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );
    402402
    403403                        // add copy ctor:  void ?{}(T *, T)
    404404                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false );
    405                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    406                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    407                         td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );
     405                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     406                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     407                        td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );
    408408
    409409                        // add default ctor:  void ?{}(T *)
    410410                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );
    411                         ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    412                         td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );
     411                        ctorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     412                        td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );
    413413
    414414                        // add assignment operator:  T * ?=?(T *, T)
    415415                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), false );
    416                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    417                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    418                         assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    419                         td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );
     416                        assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     417                        assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     418                        assignType->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     419                        td->get_assertions().push_front( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );
    420420                } // if
    421421        } // for
     
    493493
    494494Type::Qualifiers buildQualifiers( const TypeData * td ) {
    495         Type::Qualifiers q;
    496         q.isConst = td->typeQualifiers[ DeclarationNode::Const ];
    497         q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ];
    498         q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ];
    499         q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ];
    500         q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];;
    501         return q;
     495        return td->qualifiers;
    502496} // buildQualifiers
    503497
     
    732726} // buildAggInst
    733727
    734 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClasses scs ) {
     728NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) {
    735729        assert( td->kind == TypeData::Symbolic );
    736730        NamedTypeDecl * ret;
     
    784778} // buildTypeof
    785779
    786 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {
     780Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {
    787781        if ( td->kind == TypeData::Function ) {
    788782                if ( td->function.idList ) {                                    // KR function ?
     
    820814                        break;
    821815                  default:
    822                         ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", DeclarationNode::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );
     816                        ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );
    823817                } // switch
    824818        } else {
    825                 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );
     819                ft->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );
    826820        } // if
    827821        return ft;
  • src/Parser/TypeData.h

    r2f26687a r1fbab5a  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  8 22:28:33 2017
    13 // Update Count     : 174
     12// Last Modified On : Thu Mar 16 08:32:39 2017
     13// Update Count     : 185
    1414//
    1515
    1616#ifndef TYPEDATA_H
    1717#define TYPEDATA_H
    18 
    19 #include <bitset>
    2018
    2119#include "ParseNode.h"
     
    7775        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
    7876
    79         typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers;
    80         TypeQualifiers typeQualifiers;
     77        Type::Qualifiers qualifiers;
    8178        DeclarationNode * forall;
    8279
     
    112109TupleType * buildTuple( const TypeData * );
    113110TypeofType * buildTypeof( const TypeData * );
    114 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
     111Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
    115112FunctionType * buildFunction( const TypeData * );
    116113void buildKRFunction( const TypeData::Function_t & function );
  • src/Parser/parser.yy

    r2f26687a r1fbab5a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  9 21:40:20 2017
    13 // Update Count     : 2292
     12// Last Modified On : Thu Mar 16 08:36:17 2017
     13// Update Count     : 2310
    1414//
    1515
     
    441441argument_expression:
    442442        // empty
    443                 { $$ = nullptr; }                                                               // use default argument
     443                { $$ = nullptr; }
     444        // | '@'                                                                                                // use default argument
     445        //      { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); }
    444446        | assignment_expression
    445447        ;
     
    14081410type_qualifier_name:
    14091411        CONST
    1410                 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Const ); }
     1412                { $$ = DeclarationNode::newTypeQualifier( Type::Const ); }
    14111413        | RESTRICT
    1412                 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Restrict ); }
     1414                { $$ = DeclarationNode::newTypeQualifier( Type::Restrict ); }
    14131415        | VOLATILE
    1414                 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Volatile ); }
     1416                { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); }
    14151417        | LVALUE                                                                                        // CFA
    1416                 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Lvalue ); }
     1418                { $$ = DeclarationNode::newTypeQualifier( Type::Lvalue ); }
    14171419        | MUTEX
    1418                 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Mutex ); }
     1420                { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); }
    14191421        | ATOMIC
    1420                 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Atomic ); }
     1422                { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); }
    14211423        | FORALL '('
    14221424                {
     
    14511453storage_class:
    14521454        EXTERN
    1453                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
     1455                { $$ = DeclarationNode::newStorageClass( Type::Extern ); }
    14541456        | STATIC
    1455                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Static ); }
     1457                { $$ = DeclarationNode::newStorageClass( Type::Static ); }
    14561458        | AUTO
    1457                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }
     1459                { $$ = DeclarationNode::newStorageClass( Type::Auto ); }
    14581460        | REGISTER
    1459                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
     1461                { $$ = DeclarationNode::newStorageClass( Type::Register ); }
    14601462        | THREADLOCAL                                                                           // C11
    1461                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }
     1463                { $$ = DeclarationNode::newStorageClass( Type::Threadlocal ); }
    14621464                // Put function specifiers here to simplify parsing rules, but separate them semantically.
    14631465        | INLINE                                                                                        // C99
    1464                 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }
     1466                { $$ = DeclarationNode::newFuncSpecifier( Type::Inline ); }
    14651467        | FORTRAN                                                                                       // C99
    1466                 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }
     1468                { $$ = DeclarationNode::newFuncSpecifier( Type::Fortran ); }
    14671469        | NORETURN                                                                                      // C11
    1468                 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }
     1470                { $$ = DeclarationNode::newFuncSpecifier( Type::Noreturn ); }
    14691471        ;
    14701472
     
    16861688        // empty
    16871689                { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name
     1690        // '@' // empty
     1691        //      { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name
    16881692        | bit_subrange_size                                                                     // no field name
    16891693                { $$ = DeclarationNode::newBitfield( $1 ); }
Note: See TracChangeset for help on using the changeset viewer.