Changeset cd7ef0b for src/Parser


Ignore:
Timestamp:
Aug 10, 2017, 3:39:11 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
38d70ab
Parents:
275f4b4 (diff), e1780a2 (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:software/cfa/cfa-cc

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r275f4b4 rcd7ef0b  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 25 10:11:00 2017
    13 // Update Count     : 551
    14 //
    15 
    16 #include <cassert>
    17 #include <cctype>
    18 #include <climits>
    19 #include <cstdio>
    20 #include <algorithm>
     12// Last Modified On : Wed Aug  2 11:12:00 2017
     13// Update Count     : 568
     14//
     15
     16#include <climits>                                                                              // access INT_MAX, UINT_MAX, LONG_MAX, ULONG_MAX, LLONG_MAX
    2117#include <sstream>
    2218
     
    2622#include "SynTree/Expression.h"
    2723#include "SynTree/Declaration.h"
    28 #include "Common/UnimplementedError.h"
    2924#include "parserutility.h"
    30 #include "Common/utility.h"
    3125
    3226using namespace std;
     
    4640// type.
    4741
    48 Type::Qualifiers noQualifiers;                          // no qualifiers on constants
     42extern const Type::Qualifiers noQualifiers;             // no qualifiers on constants
    4943
    5044static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
     
    5549static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
    5650
    57 Expression *build_constantInteger( const std::string & str ) {
     51Expression * build_constantInteger( const std::string & str ) {
    5852        static const BasicType::Kind kind[2][3] = {
    5953                { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt },
     
    6256        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    6357        int size;                                                                                       // 0 => int, 1 => long, 2 => long long
    64         unsigned long long int v;                                                               // converted integral value
     58        unsigned long long int v;                                                       // converted integral value
    6559        size_t last = str.length() - 1;                                         // last character of constant
    66 
     60        Expression * ret;
     61
     62        // special constants
     63        if ( str == "0" ) {
     64                ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) );
     65                goto CLEANUP;
     66        } // if
     67        if ( str == "1" ) {
     68                ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) );
     69                goto CLEANUP;
     70        } // if
     71       
    6772        if ( str[0] == '0' ) {                                                          // octal/hex constant ?
    6873                dec = false;
     
    118123        } // if
    119124
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
     125        ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
     126  CLEANUP:
    121127        delete &str;                                                                            // created by lex
    122128        return ret;
    123129} // build_constantInteger
    124130
    125 Expression *build_constantFloat( const std::string & str ) {
     131Expression * build_constantFloat( const std::string & str ) {
    126132        static const BasicType::Kind kind[2][3] = {
    127133                { BasicType::Float, BasicType::Double, BasicType::LongDouble },
     
    158164} // build_constantFloat
    159165
    160 Expression *build_constantChar( const std::string & str ) {
     166Expression * build_constantChar( const std::string & str ) {
    161167        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
    162168        delete &str;                                                                            // created by lex
     
    164170} // build_constantChar
    165171
    166 ConstantExpr *build_constantStr( const std::string & str ) {
     172ConstantExpr * build_constantStr( const std::string & str ) {
    167173        // string should probably be a primitive type
    168         ArrayType *at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    169                                                                    new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
     174        ArrayType * at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
     175                                                                   new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
    170176                                                                   false, false );
    171         // constant 0 is ignored for pure string value
    172         ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) );
     177        ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); // constant 0 is ignored for pure string value
    173178        delete &str;                                                                            // created by lex
    174179        return ret;
    175180} // build_constantStr
    176 
    177 Expression *build_constantZeroOne( const std::string & str ) {
    178         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( noQualifiers ) : (Type*)new OneType( noQualifiers ), str,
    179                                                                                                    str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
    180         delete &str;                                                                            // created by lex
    181         return ret;
    182 } // build_constantChar
    183181
    184182Expression * build_field_name_FLOATINGconstant( const std::string & str ) {
     
    209207} // build_field_name_fraction_constants
    210208
    211 
    212 
    213209Expression * build_field_name_REALFRACTIONconstant( const std::string & str ) {
    214210        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( "invalid tuple index " + str );
     
    225221} // build_field_name_REALDECIMALconstant
    226222
    227 NameExpr * build_varref( const string *name ) {
    228         NameExpr *expr = new NameExpr( *name, nullptr );
     223NameExpr * build_varref( const string * name ) {
     224        NameExpr * expr = new NameExpr( *name, nullptr );
    229225        delete name;
    230226        return expr;
    231 }
    232 
    233 // Must harmonize with OperKinds.
    234 static const char *OperName[] = {
     227} // build_varref
     228
     229
     230static const char * OperName[] = {                                              // must harmonize with OperKinds
    235231        // diadic
    236232        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
     
    240236        // monadic
    241237        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&"
    242 };
    243 
    244 Expression *build_cast( DeclarationNode *decl_node, ExpressionNode *expr_node ) {
    245         Type *targetType = maybeMoveBuildType( decl_node );
     238}; // OperName
     239
     240Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
     241        Type * targetType = maybeMoveBuildType( decl_node );
    246242        if ( dynamic_cast< VoidType * >( targetType ) ) {
    247243                delete targetType;
     
    250246                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
    251247        } // if
    252 }
    253 
    254 
    255 Expression *build_virtual_cast( DeclarationNode *decl_node, ExpressionNode *expr_node ) {
    256         Type *targetType = maybeMoveBuildType( decl_node );
    257         Expression *castArg = maybeMoveBuild< Expression >( expr_node );
     248} // build_cast
     249
     250Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
     251        Type * targetType = maybeMoveBuildType( decl_node );
     252        Expression * castArg = maybeMoveBuild< Expression >( expr_node );
    258253        return new VirtualCastExpr( castArg, targetType );
    259 }
    260 
    261 Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) {
    262         UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
    263         return ret;
    264 }
    265 
    266 Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) {
    267         UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
     254} // build_virtual_cast
     255
     256Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) {
     257        UntypedMemberExpr * ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
     258        return ret;
     259} // build_fieldSel
     260
     261Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ) {
     262        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
    268263        deref->location = expr_node->location;
    269264        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
    270         UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref );
    271         return ret;
    272 }
    273 
    274 Expression *build_addressOf( ExpressionNode *expr_node ) {
     265        UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref );
     266        return ret;
     267} // build_pfieldSel
     268
     269Expression * build_addressOf( ExpressionNode * expr_node ) {
    275270                return new AddressExpr( maybeMoveBuild< Expression >(expr_node) );
    276 }
    277 Expression *build_sizeOfexpr( ExpressionNode *expr_node ) {
     271} // build_addressOf
     272
     273Expression * build_sizeOfexpr( ExpressionNode * expr_node ) {
    278274        return new SizeofExpr( maybeMoveBuild< Expression >(expr_node) );
    279 }
    280 Expression *build_sizeOftype( DeclarationNode *decl_node ) {
     275} // build_sizeOfexpr
     276
     277Expression * build_sizeOftype( DeclarationNode * decl_node ) {
    281278        return new SizeofExpr( maybeMoveBuildType( decl_node ) );
    282 }
    283 Expression *build_alignOfexpr( ExpressionNode *expr_node ) {
     279} // build_sizeOftype
     280
     281Expression * build_alignOfexpr( ExpressionNode * expr_node ) {
    284282        return new AlignofExpr( maybeMoveBuild< Expression >(expr_node) );
    285 }
    286 Expression *build_alignOftype( DeclarationNode *decl_node ) {
     283} // build_alignOfexpr
     284
     285Expression * build_alignOftype( DeclarationNode * decl_node ) {
    287286        return new AlignofExpr( maybeMoveBuildType( decl_node) );
    288 }
    289 Expression *build_offsetOf( DeclarationNode *decl_node, NameExpr *member ) {
     287} // build_alignOftype
     288
     289Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
    290290        Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );
    291291        delete member;
    292292        return ret;
    293 }
    294 
    295 Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) {
     293} // build_offsetOf
     294
     295Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ) {
    296296        return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );
    297 }
    298 
    299 Expression *build_unary_val( OperKinds op, ExpressionNode *expr_node ) {
     297} // build_and_or
     298
     299Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ) {
    300300        std::list< Expression * > args;
    301301        args.push_back( maybeMoveBuild< Expression >(expr_node) );
    302302        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    303 }
    304 Expression *build_unary_ptr( OperKinds op, ExpressionNode *expr_node ) {
     303} // build_unary_val
     304
     305Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) {
    305306        std::list< Expression * > args;
    306307        args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node) ) );
    307308        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    308 }
    309 Expression *build_binary_val( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
     309} // build_unary_ptr
     310
     311Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
    310312        std::list< Expression * > args;
    311313        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
    312314        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
    313315        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    314 }
    315 Expression *build_binary_ptr( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
     316} // build_binary_val
     317
     318Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
    316319        std::list< Expression * > args;
    317320        args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node1) ) );
    318321        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
    319322        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    320 }
    321 
    322 Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) {
     323} // build_binary_ptr
     324
     325Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ) {
    323326        return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );
    324 }
    325 
    326 Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
     327} // build_cond
     328
     329Expression * build_comma( ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
    327330        return new CommaExpr( maybeMoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) );
    328 }
    329 
    330 Expression *build_attrexpr( NameExpr *var, ExpressionNode * expr_node ) {
     331} // build_comma
     332
     333Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node ) {
    331334        return new AttrExpr( var, maybeMoveBuild< Expression >(expr_node) );
    332 }
    333 Expression *build_attrtype( NameExpr *var, DeclarationNode * decl_node ) {
     335} // build_attrexpr
     336
     337Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node ) {
    334338        return new AttrExpr( var, maybeMoveBuildType( decl_node ) );
    335 }
    336 
    337 Expression *build_tuple( ExpressionNode * expr_node ) {
     339} // build_attrtype
     340
     341Expression * build_tuple( ExpressionNode * expr_node ) {
    338342        std::list< Expression * > exprs;
    339343        buildMoveList( expr_node, exprs );
    340344        return new UntypedTupleExpr( exprs );;
    341 }
    342 
    343 Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
     345} // build_tuple
     346
     347Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
    344348        std::list< Expression * > args;
    345349        buildMoveList( expr_node, args );
    346350        return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr );
    347 }
    348 
    349 Expression *build_range( ExpressionNode * low, ExpressionNode *high ) {
     351} // build_func
     352
     353Expression * build_range( ExpressionNode * low, ExpressionNode * high ) {
    350354        return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) );
    351 }
    352 
    353 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {
     355} // build_range
     356
     357Expression * build_asmexpr( ExpressionNode * inout, ConstantExpr * constraint, ExpressionNode * operand ) {
    354358        return new AsmExpr( maybeMoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) );
    355 }
    356 
    357 Expression *build_valexpr( StatementNode *s ) {
     359} // build_asmexpr
     360
     361Expression * build_valexpr( StatementNode * s ) {
    358362        return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) );
    359 }
    360 Expression *build_typevalue( DeclarationNode *decl ) {
     363} // build_valexpr
     364
     365Expression * build_typevalue( DeclarationNode * decl ) {
    361366        return new TypeExpr( maybeMoveBuildType( decl ) );
    362 }
    363 
    364 Expression *build_compoundLiteral( DeclarationNode *decl_node, InitializerNode *kids ) {
     367} // build_typevalue
     368
     369Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) {
    365370        Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type
    366371        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
     
    388393                assert( false );
    389394        } // if
    390 }
     395} // build_compoundLiteral
    391396
    392397// Local Variables: //
  • src/Parser/InitializerNode.cc

    r275f4b4 rcd7ef0b  
    1010// Created On       : Sat May 16 13:20:24 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  1 23:09:51 2016
    13 // Update Count     : 21
     12// Last Modified On : Fri Jul 28 23:27:20 2017
     13// Update Count     : 26
    1414//
    1515
     
    2222#include "SynTree/Initializer.h"
    2323
    24 InitializerNode::InitializerNode( ExpressionNode *_expr, bool aggrp, ExpressionNode *des )
    25                 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) {
     24InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des )
     25                : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {
    2626        if ( aggrp )
    2727                kids = dynamic_cast< InitializerNode * >( get_next() );
    2828
    29         if ( kids != 0 )
    30                 set_last( 0 );
    31 }
     29        if ( kids )
     30                set_last( nullptr );
     31} // InitializerNode::InitializerNode
    3232
    33 InitializerNode::InitializerNode( InitializerNode *init, bool aggrp, ExpressionNode *des )
    34                 : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) {
    35         if ( init != 0 )
     33InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode * des )
     34                : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {
     35        if ( init )
    3636                set_last( init );
    3737
     
    3939                kids = dynamic_cast< InitializerNode * >( get_next() );
    4040
    41         if ( kids != 0 )
    42                 set_next( 0 );
    43 }
     41        if ( kids )
     42                set_next( nullptr );
     43} // InitializerNode::InitializerNode
    4444
    4545InitializerNode::~InitializerNode() {
     
    4747        delete designator;
    4848        delete kids;
    49 }
     49} // InitializerNode::~InitializerNode
    5050
    5151void InitializerNode::print( std::ostream &os, int indent ) const {
    5252        os << std::string( indent, ' ' ) << "Initializer expression" << std::endl;
    53 }
     53} // InitializerNode::print
    5454
    5555void InitializerNode::printOneLine( std::ostream &os ) const {
    5656        if ( ! aggregate ) {
    57                 if ( designator != 0 ) {
     57                if ( designator ) {
    5858                        os << "designated by: (";
    5959                        ExpressionNode *curdes = designator;
    60                         while ( curdes != 0) {
     60                        while ( curdes != nullptr) {
    6161                                curdes->printOneLine(os);
    6262                                curdes = (ExpressionNode *)(curdes->get_next());
     
    6565                        os << ")";
    6666                } // if
    67                 if ( expr ) expr->printOneLine(os);
     67                if ( expr ) expr->printOneLine( os );
    6868        } else {  // It's an aggregate
    6969                os << "[--";
    70                 if ( next_init() != 0 )
    71                         next_init()->printOneLine(os);
     70                if ( next_init() != nullptr )
     71                        next_init()->printOneLine( os );
    7272                if (aggregate) os << "--]";
    7373        } // if
     
    7676        if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
    7777                moreInit->printOneLine( os );
    78         }
    79 }
     78        } // if
     79} // InitializerNode::printOneLine
    8080
    81 Initializer *InitializerNode::build() const {
     81Initializer * InitializerNode::build() const {
    8282        if ( aggregate ) {
    8383                // steal designators from children
     
    9393                return new ListInit( initlist, designlist, maybeConstructed );
    9494        } else {
    95                 if ( get_expression() != 0) {
     95                if ( get_expression() ) {
    9696                        return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
    97                 }
     97                } // if
    9898        } // if
    99         return 0;
    100 }
     99        return nullptr;
     100} // InitializerNode::build
    101101
    102102// Local Variables: //
  • src/Parser/ParseNode.h

    r275f4b4 rcd7ef0b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 25 10:09:00 2017
    13 // Update Count     : 787
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 27 12:08:08 2017
     13// Update Count     : 788
    1414//
    1515
     
    159159Expression * build_constantFloat( const std::string &str );
    160160Expression * build_constantChar( const std::string &str );
    161 Expression * build_constantZeroOne( const std::string &str );
    162161ConstantExpr * build_constantStr( const std::string &str );
    163162Expression * build_field_name_FLOATINGconstant( const std::string & str );
  • src/Parser/TypeData.cc

    r275f4b4 rcd7ef0b  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 18 10:10:00 2017
    13 // Update Count     : 566
     12// Last Modified On : Wed Aug  9 13:50:00 2017
     13// Update Count     : 567
    1414//
    1515
     
    748748} // buildAggInst
    749749
    750 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) {
     750NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) {
    751751        assert( td->kind == TypeData::Symbolic );
    752752        NamedTypeDecl * ret;
    753753        assert( td->base );
    754754        if ( td->symbolic.isTypedef ) {
    755                 ret = new TypedefDecl( name, scs, typebuild( td->base ) );
     755                ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage );
    756756        } else {
    757757                ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Any );
     
    817817                return buildEnum( td, attributes );
    818818        } else if ( td->kind == TypeData::Symbolic ) {
    819                 return buildSymbolic( td, name, scs );
     819                return buildSymbolic( td, name, scs, linkage );
    820820        } else {
    821821                return (new ObjectDecl( name, scs, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName );
  • src/Parser/lex.ll

    r275f4b4 rcd7ef0b  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Mon Jul 24 08:27:23 2017
    13  * Update Count     : 545
     12 * Last Modified On : Thu Jul 27 21:46:06 2017
     13 * Update Count     : 550
    1414 */
    1515
    1616%option yylineno
     17%option noyywrap
    1718%option nounput
    1819
     
    288289
    289290                                /* numeric constants */
    290 "0"                             { NUMERIC_RETURN(ZERO); }                               // CFA
    291 "1"                             { NUMERIC_RETURN(ONE); }                                // CFA
    292291{decimal_constant} { NUMERIC_RETURN(INTEGERconstant); }
    293292{octal_constant} { NUMERIC_RETURN(INTEGERconstant); }
     
    420419
    421420                                /* unknown characters */
    422 .                       { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }
     421.                               { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }
    423422
    424423%%
  • src/Parser/parser.yy

    r275f4b4 rcd7ef0b  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 25 10:07:00 2017
    13 // Update Count     : 2464
     12// Last Modified On : Wed Aug  4 13:33:00 2017
     13// Update Count     : 2475
    1414//
    1515
     
    142142// converted into the tuple index (.)(1). e.g., 3.x
    143143%token<tok>     REALDECIMALconstant     REALFRACTIONconstant    FLOATINGconstant
    144 %token<tok> ZERO                                ONE                                             // CFA
    145144
    146145// multi-character operators
     
    159158%token ATassign                                                                                 // @=
    160159
    161 %type<tok> identifier  no_attr_identifier  zero_one
     160%type<tok> identifier  no_attr_identifier
    162161%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
    163162%type<constant> string_literal
     
    183182%type<en> asm_clobbers_list_opt
    184183%type<flag> asm_volatile_opt
     184%type<en> handler_predicate_opt
    185185
    186186// statements
     
    360360        ;
    361361
    362 zero_one:                                                                                               // CFA
    363         ZERO
    364         | ONE
    365         ;
    366 
    367362string_literal:
    368363        string_literal_list                                                     { $$ = build_constantStr( *$1 ); }
     
    384379        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    385380                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    386         | zero_one
    387                 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }
    388381        | tuple
    389382        | '(' comma_expression ')'
     
    485478                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    486479                }
    487         | zero_one fraction_constants
    488                 {
    489                         $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
    490                 }
    491480        ;
    492481
     
    539528        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    540529                { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
    541         | ALIGNOF '(' type_no_function ')'                              // GCC, type alignment
     530        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    542531                { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    543532        | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     
    980969
    981970handler_clause:
    982         // TEMPORARY, TEST EXCEPTIONS
    983         handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
    984                 { $$ = new StatementNode( build_catch( $1, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); }
    985         | handler_clause handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
    986                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
    987 
    988         | handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    989                 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); }
     971        handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     972                { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); }
    990973        | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    991                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); }
     974                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); }
    992975        ;
    993976
    994977handler_predicate_opt:
    995978        //empty
     979                { $$ = nullptr; }
    996980        | ';' conditional_expression
     981                { $$ = $2; }
    997982        ;
    998983
     
    16861671        | aggregate_key attribute_list_opt typegen_name         // CFA
    16871672                { $$ = $3->addQualifiers( $2 ); }
    1688 
    1689 // Temp, testing TreeStruct
    1690     | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name
    1691         {
    1692             typedefTable.makeTypedef( *$4 );            // create typedef
    1693             if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
    1694             forall = false;                             // reset
    1695         }
    1696       '{' field_declaration_list '}'
    1697         {
    1698             $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
    1699                 $4, nullptr, nullptr, $7, true )->addQualifiers( $3 );
    1700         }
    1701     | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name TYPEDEFname
    1702         {
    1703             typedefTable.makeTypedef( *$4 );            // create typedef
    1704             if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
    1705             forall = false;                             // reset
    1706         }
    1707       '{' field_declaration_list '}'
    1708         {
    1709             $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
    1710                 $4, $5, nullptr, $8, true )->addQualifiers( $3 );
    1711         }
    17121673        ;
    17131674
     
    19691930        | '=' initializer
    19701931                { $$ = $2; }
     1932        | '=' VOID
     1933                { $$ = nullptr; }
    19711934        | ATassign initializer
    19721935                { $$ = $2->set_maybeConstructed( false ); }
Note: See TracChangeset for help on using the changeset viewer.