Changeset 99cadc60 for src


Ignore:
Timestamp:
Jul 31, 2019, 3:26:06 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
61cfae2
Parents:
c60a664 (diff), 40287c8 (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
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rc60a664 r99cadc60  
    99// Author           : Thierry Delisle
    1010// Created On       : Thu May 09 15::37::05 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 17 16:44:00 2019
    13 // Update Count     : 12
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 25 22:21:46 2019
     13// Update Count     : 13
    1414//
    1515
     
    26762676                );
    26772677        }
    2678 
    2679         virtual void visit( const AttrExpr * ) override final {
    2680                 assertf( false, "AttrExpr deprecated in new AST." );
    2681         }
    26822678};
    26832679
  • src/AST/porting.md

    rc60a664 r99cadc60  
    171171  * all existing uses assume `type` set if true and don't use `expr`
    172172
    173 `AttrExpr`
    174 * did not port due to feature deprecation (e.g. `expr@attribute`)
    175 
    176173`LogicalExpr`
    177174* un-defaulted constructor parameter determining `&&` or `||`
  • src/Common/Eval.cc

    rc60a664 r99cadc60  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May  6 22:24:16 2018
    13 // Update Count     : 40
     12// Last Modified On : Wed Jul 24 15:09:06 2019
     13// Update Count     : 64
    1414//
    1515
     
    2727        bool valid = true;
    2828
    29         void previsit( BaseSyntaxNode * ) { visit_children = false; }
    30         void postvisit( BaseSyntaxNode * ) { valid = false; }
     29        void previsit( const BaseSyntaxNode * ) { visit_children = false; }
     30        void postvisit( const BaseSyntaxNode * ) { valid = false; }
    3131
    32         void postvisit( ConstantExpr * expr ) {
     32        void postvisit( const SizeofExpr * ) {
     33        }
     34
     35        void postvisit( const ConstantExpr * expr ) {
    3336                value = expr->intValue();
    3437        }
    3538
    36         void postvisit( CastExpr * expr ) {
     39        void postvisit( const CastExpr * expr ) {
    3740                auto arg = eval(expr->arg);
    3841                valid = arg.second;
     
    4144        }
    4245
    43         void postvisit( VariableExpr * expr ) {
     46        void postvisit( const VariableExpr * const expr ) {
    4447                if ( EnumInstType * inst = dynamic_cast<EnumInstType *>(expr->result) ) {
    4548                        if ( EnumDecl * decl = inst->baseEnum ) {
     
    5255        }
    5356
    54         void postvisit( ApplicationExpr * expr ) {
    55                 DeclarationWithType * function = InitTweak::getFunction(expr);
     57        void postvisit( const ApplicationExpr * expr ) {
     58                DeclarationWithType * function = InitTweak::getFunction(const_cast<ApplicationExpr *>(expr));
    5659                if ( ! function || function->linkage != LinkageSpec::Intrinsic ) { valid = false; return; }
    5760                const std::string & fname = function->name;
     
    9497        void postvisit( const ast::ConstantExpr * expr ) {
    9598                value = expr->intValue();
     99        }
     100
     101        void postvisit( const ast::SizeofExpr * expr ) {
     102                if ( expr->expr ) value = eval(expr->expr).first;
     103                else if ( expr->type ) value = eval(expr->expr).first;
     104                else SemanticError( expr->location, ::toString( "Internal error: SizeofExpr has no expression or type value" ) );
    96105        }
    97106
     
    145154};
    146155
    147 std::pair<long long int, bool> eval(Expression * expr) {
     156std::pair<long long int, bool> eval( const Expression * expr) {
    148157        PassVisitor<EvalOld> ev;
    149158        if (expr) {
  • src/Common/PassVisitor.h

    rc60a664 r99cadc60  
    155155        virtual void visit( OffsetPackExpr * offsetPackExpr ) override final;
    156156        virtual void visit( const OffsetPackExpr * offsetPackExpr ) override final;
    157         virtual void visit( AttrExpr * attrExpr ) override final;
    158         virtual void visit( const AttrExpr * attrExpr ) override final;
    159157        virtual void visit( LogicalExpr * logicalExpr ) override final;
    160158        virtual void visit( const LogicalExpr * logicalExpr ) override final;
     
    301299        virtual Expression * mutate( OffsetofExpr * offsetofExpr ) override final;
    302300        virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) override final;
    303         virtual Expression * mutate( AttrExpr * attrExpr ) override final;
    304301        virtual Expression * mutate( LogicalExpr * logicalExpr ) override final;
    305302        virtual Expression * mutate( ConditionalExpr * conditionalExpr ) override final;
  • src/Common/PassVisitor.impl.h

    rc60a664 r99cadc60  
    23022302
    23032303//--------------------------------------------------------------------------
    2304 // AttrExpr
    2305 template< typename pass_type >
    2306 void PassVisitor< pass_type >::visit( AttrExpr * node ) {
    2307         VISIT_START( node );
    2308 
    2309         indexerScopedAccept( node->result, *this );
    2310         if ( node->get_isType() ) {
    2311                 maybeAccept_impl( node->type, *this );
    2312         } else {
    2313                 maybeAccept_impl( node->expr, *this );
    2314         }
    2315 
    2316         VISIT_END( node );
    2317 }
    2318 
    2319 template< typename pass_type >
    2320 void PassVisitor< pass_type >::visit( const AttrExpr * node ) {
    2321         VISIT_START( node );
    2322 
    2323         indexerScopedAccept( node->result, *this );
    2324         if ( node->get_isType() ) {
    2325                 maybeAccept_impl( node->type, *this );
    2326         } else {
    2327                 maybeAccept_impl( node->expr, *this );
    2328         }
    2329 
    2330         VISIT_END( node );
    2331 }
    2332 
    2333 template< typename pass_type >
    2334 Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
    2335         MUTATE_START( node );
    2336 
    2337         indexerScopedMutate( node->env   , *this );
    2338         indexerScopedMutate( node->result, *this );
    2339         if ( node->get_isType() ) {
    2340                 maybeMutate_impl( node->type, *this );
    2341         } else {
    2342                 maybeMutate_impl( node->expr, *this );
    2343         }
    2344 
    2345         MUTATE_END( Expression, node );
    2346 }
    2347 
    2348 //--------------------------------------------------------------------------
    23492304// LogicalExpr
    23502305template< typename pass_type >
  • src/Common/utility.h

    rc60a664 r99cadc60  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May  6 22:24:16 2018
    13 // Update Count     : 40
     12// Last Modified On : Wed Jul 24 14:28:19 2019
     13// Update Count     : 41
    1414//
    1515
     
    483483// -----------------------------------------------------------------------------
    484484/// evaluates expr as a long long int. If second is false, expr could not be evaluated
    485 std::pair<long long int, bool> eval(Expression * expr);
     485std::pair<long long int, bool> eval(const Expression * expr);
    486486
    487487namespace ast {
  • src/InitTweak/InitTweak.cc

    rc60a664 r99cadc60  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri May 13 11:26:36 2016
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jun 19 14:34:00 2019
    13 // Update Count     : 6
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 25 22:21:48 2019
     13// Update Count     : 7
    1414//
    1515
     
    957957                void previsit( OffsetofExpr * ) {}
    958958                void previsit( OffsetPackExpr * ) {}
    959                 void previsit( AttrExpr * ) {}
    960959                void previsit( CommaExpr * ) {}
    961960                void previsit( LogicalExpr * ) {}
  • src/Parser/DeclarationNode.cc

    rc60a664 r99cadc60  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  1 16:49:17 2019
    13 // Update Count     : 1113
     12// Last Modified On : Thu Jul 25 22:17:10 2019
     13// Update Count     : 1116
    1414//
    1515
     
    4949const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };
    5050const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };
    51 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "zero_t", "one_t", "NoBuiltinTypeNames" };
     51const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" };
    5252
    5353UniqueName DeclarationNode::anonymous( "__anonymous" );
     
    418418        return newnode;
    419419} // DeclarationNode::newBuiltinType
    420 
    421 DeclarationNode * DeclarationNode::newAttr( const string * name, ExpressionNode * expr ) {
    422         DeclarationNode * newnode = new DeclarationNode;
    423         newnode->type = nullptr;
    424 //      newnode->attr.name = name;
    425         newnode->name = name;
    426         newnode->attr.expr = expr;
    427         return newnode;
    428 }
    429 
    430 DeclarationNode * DeclarationNode::newAttr( const string * name, DeclarationNode * type ) {
    431         DeclarationNode * newnode = new DeclarationNode;
    432         newnode->type = nullptr;
    433 //      newnode->attr.name = name;
    434         newnode->name = name;
    435         newnode->attr.type = type;
    436         return newnode;
    437 }
    438420
    439421DeclarationNode * DeclarationNode::newAttribute( const string * name, ExpressionNode * expr ) {
  • src/Parser/ParseNode.h

    rc60a664 r99cadc60  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 15 14:22:39 2019
    13 // Update Count     : 874
     12// Last Modified On : Thu Jul 25 22:17:10 2019
     13// Update Count     : 876
    1414//
    1515
     
    221221        enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };
    222222        static const char * typeClassNames[];
    223         enum BuiltinType { Valist, Zero, One, NoBuiltinType };
     223        enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType };
    224224        static const char * builtinTypeNames[];
    225225
     
    252252        static DeclarationNode * newTuple( DeclarationNode * members );
    253253        static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false );
    254         static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes
    255         static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes
    256254        static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    257255        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
  • src/Parser/lex.ll

    rc60a664 r99cadc60  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed May 15 21:25:27 2019
    13  * Update Count     : 708
     12 * Last Modified On : Thu Jul 25 22:08:32 2019
     13 * Update Count     : 716
    1414 */
    1515
     
    5959#define QKEYWORD_RETURN(x)      RETURN_VAL(x);                          // quasi-keyword
    6060#define IDENTIFIER_RETURN()     RETURN_VAL( typedefTable.isKind( yytext ) )
    61 #define ATTRIBUTE_RETURN()      RETURN_VAL( ATTR_IDENTIFIER )
    6261
    6362#ifdef HAVE_KEYWORDS_FLOATXX                                                            // GCC >= 7 => keyword, otherwise typedef
     
    9291                                // identifier, GCC: $ in identifier
    9392identifier ([a-zA-Z_$]|{universal_char})([0-9a-zA-Z_$]|{universal_char})*
    94 
    95                                 // attribute identifier, GCC: $ in identifier
    96 attr_identifier "@"{identifier}
    9793
    9894                                // numeric constants, CFA: '_' in constant
     
    218214__attribute__   { KEYWORD_RETURN(ATTRIBUTE); }                  // GCC
    219215auto                    { KEYWORD_RETURN(AUTO); }
     216__auto_type             { KEYWORD_RETURN(AUTO_TYPE); }
    220217basetypeof              { KEYWORD_RETURN(BASETYPEOF); }                 // CFA
    221218_Bool                   { KEYWORD_RETURN(BOOL); }                               // C99
     
    292289__restrict__    { KEYWORD_RETURN(RESTRICT); }                   // GCC
    293290return                  { KEYWORD_RETURN(RETURN); }
     291        /* resume                       { KEYWORD_RETURN(RESUME); }                             // CFA */
    294292short                   { KEYWORD_RETURN(SHORT); }
    295293signed                  { KEYWORD_RETURN(SIGNED); }
     
    300298_Static_assert  { KEYWORD_RETURN(STATICASSERT); }               // C11
    301299struct                  { KEYWORD_RETURN(STRUCT); }
     300        /* suspend                      { KEYWORD_RETURN(SUSPEND); }                    // CFA */
    302301switch                  { KEYWORD_RETURN(SWITCH); }
    303302thread                  { KEYWORD_RETURN(THREAD); }                             // C11
     
    333332        IDENTIFIER_RETURN();
    334333}
    335 {attr_identifier} { ATTRIBUTE_RETURN(); }
    336334
    337335                                /* numeric constants */
  • src/Parser/parser.yy

    rc60a664 r99cadc60  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 14 07:54:30 2019
    13 // Update Count     : 4355
     12// Last Modified On : Thu Jul 25 22:31:38 2019
     13// Update Count     : 4359
    1414//
    1515
     
    272272%token ZERO_T ONE_T                                                                             // CFA
    273273%token VALIST                                                                                   // GCC
     274%token AUTO_TYPE                                                                                // GCC
    274275%token TYPEOF BASETYPEOF LABEL                                                  // GCC
    275276%token ENUM STRUCT UNION
     
    288289%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    289290%token<tok> TIMEOUT                             WOR
    290 %token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    291291%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
    292292%token<tok> DIRECTIVE
     
    312312%token ATassign                                                                                 // @=
    313313
    314 %type<tok> identifier  no_attr_identifier
    315 %type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
     314%type<tok> identifier
     315%type<tok> identifier_or_type_name  attr_name
    316316%type<tok> quasi_keyword
    317317%type<constant> string_literal
     
    546546        ;
    547547
    548 no_attr_identifier:
     548identifier:
    549549        IDENTIFIER
    550550        | quasi_keyword
    551551        | '@'                                                                                           // CFA
    552552                { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; }
    553         ;
    554 
    555 identifier:
    556         no_attr_identifier
    557         | ATTR_IDENTIFIER                                                                       // CFA
    558553        ;
    559554
     
    594589        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    595590                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    596         | type_name '.' no_attr_identifier                                      // CFA, nested type
     591        | type_name '.' identifier                                                      // CFA, nested type
    597592                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    598593        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
     
    647642        | postfix_expression '(' argument_expression_list ')'
    648643                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    649         | postfix_expression '.' no_attr_identifier
     644        | postfix_expression '.' identifier
    650645                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    651646        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
     
    655650        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    656651                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    657         | postfix_expression ARROW no_attr_identifier
     652        | postfix_expression ARROW identifier
    658653                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    659654        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
     
    718713        | FLOATINGconstant fraction_constants_opt
    719714                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    720         | no_attr_identifier fraction_constants_opt
     715        | identifier fraction_constants_opt
    721716                {
    722717                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    776771        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    777772                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
    778         | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     773        | OFFSETOF '(' type_no_function ',' identifier ')'
    779774                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    780         | ATTR_IDENTIFIER
    781                 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ) ) ); }
    782         | ATTR_IDENTIFIER '(' argument_expression ')'
    783                 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }
    784         | ATTR_IDENTIFIER '(' type ')'
    785                 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuildType( $3 ) ) ); }
    786775        ;
    787776
     
    10181007
    10191008labeled_statement:
    1020                 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER
     1009                // labels cannot be identifiers 0 or 1
    10211010        identifier_or_type_name ':' attribute_list_opt statement
    10221011                { $$ = $4->add_label( $1, $3 ); }
     
    13861375        | type_specifier_nobody variable_abstract_declarator
    13871376                { $$ = $2->addType( $1 ); }
    1388         | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
     1377        | cfa_abstract_declarator_tuple identifier                      // CFA
    13891378                { $$ = $1->addName( $2 ); }
    13901379        | cfa_abstract_declarator_tuple                                         // CFA
     
    14501439
    14511440label_list:
    1452         no_attr_identifier
     1441        identifier
    14531442                {
    14541443                        $$ = new LabelNode(); $$->labels.push_back( *$1 );
    14551444                        delete $1;                                                                      // allocated by lexer
    14561445                }
    1457         | label_list ',' no_attr_identifier
     1446        | label_list ',' identifier
    14581447                {
    14591448                        $$ = $1; $1->labels.push_back( *$3 );
     
    15001489
    15011490local_label_list:                                                                               // GCC, local label
    1502         no_attr_identifier_or_type_name
    1503         | local_label_list ',' no_attr_identifier_or_type_name
     1491        identifier_or_type_name
     1492        | local_label_list ',' identifier_or_type_name
    15041493        ;
    15051494
     
    16231612                        $$ = $2->addTypedef();
    16241613                }
    1625         | cfa_typedef_declaration pop ',' push no_attr_identifier
     1614        | cfa_typedef_declaration pop ',' push identifier
    16261615                {
    16271616                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
     
    16631652typedef_expression:
    16641653                // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    1665         TYPEDEF no_attr_identifier '=' assignment_expression
     1654        TYPEDEF identifier '=' assignment_expression
    16661655                {
    16671656                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    16681657                        SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
    16691658                }
    1670         | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression
     1659        | typedef_expression pop ',' push identifier '=' assignment_expression
    16711660                {
    16721661                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
     
    18711860        | VALIST                                                                                        // GCC, __builtin_va_list
    18721861                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     1862        | AUTO_TYPE
     1863                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }
    18731864        ;
    18741865
     
    19121903        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
    19131904                { $$ = DeclarationNode::newTypeof( $3, true ); }
    1914         | ATTR_TYPEGENname '(' type ')'                                         // CFA: e.g., @type( x ) y;
    1915                 { $$ = DeclarationNode::newAttr( $1, $3 ); }
    1916         | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type( a+b ) y;
    1917                 { $$ = DeclarationNode::newAttr( $1, $3 ); }
    19181905        | ZERO_T                                                                                        // CFA
    19191906                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     
    20242011          '{' field_declaration_list_opt '}' type_parameters_opt
    20252012                { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); }
    2026         | aggregate_key attribute_list_opt no_attr_identifier fred
     2013        | aggregate_key attribute_list_opt identifier fred
    20272014                {
    20282015                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     
    20502037
    20512038aggregate_type_nobody:                                                                  // struct, union - {...}
    2052         aggregate_key attribute_list_opt no_attr_identifier fred
     2039        aggregate_key attribute_list_opt identifier fred
    20532040                {
    20542041                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
     
    21512138cfa_field_declaring_list:                                                               // CFA, new style field declaration
    21522139        // bit-fields are handled by C declarations
    2153         cfa_abstract_declarator_tuple no_attr_identifier_or_type_name
     2140        cfa_abstract_declarator_tuple identifier_or_type_name
    21542141                { $$ = $1->addName( $2 ); }
    2155         | cfa_field_declaring_list ',' no_attr_identifier_or_type_name
     2142        | cfa_field_declaring_list ',' identifier_or_type_name
    21562143                { $$ = $1->appendList( $1->cloneType( $3 ) ); }
    21572144        ;
     
    21782165        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    21792166                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2180         | ENUM attribute_list_opt no_attr_identifier
     2167        | ENUM attribute_list_opt identifier
    21812168                { typedefTable.makeTypedef( *$3 ); }
    21822169          '{' enumerator_list comma_opt '}'
     
    21892176
    21902177enum_type_nobody:                                                                               // enum - {...}
    2191         ENUM attribute_list_opt no_attr_identifier
     2178        ENUM attribute_list_opt identifier
    21922179                {
    21932180                        typedefTable.makeTypedef( *$3 );
     
    22022189
    22032190enumerator_list:
    2204         no_attr_identifier_or_type_name enumerator_value_opt
     2191        identifier_or_type_name enumerator_value_opt
    22052192                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    2206         | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt
     2193        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    22072194                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    22082195        ;
     
    23122299
    23132300identifier_list:                                                                                // K&R-style parameter list => no types
    2314         no_attr_identifier
     2301        identifier
    23152302                { $$ = DeclarationNode::newName( $1 ); }
    2316         | identifier_list ',' no_attr_identifier
     2303        | identifier_list ',' identifier
    23172304                { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); }
    23182305        ;
     
    23202307identifier_or_type_name:
    23212308        identifier
    2322         | TYPEDEFname
    2323         | TYPEGENname
    2324         ;
    2325 
    2326 no_attr_identifier_or_type_name:
    2327         no_attr_identifier
    23282309        | TYPEDEFname
    23292310        | TYPEGENname
     
    23802361designation:
    23812362        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    2382         | no_attr_identifier ':'                                                        // GCC, field name
     2363        | identifier ':'                                                                        // GCC, field name
    23832364                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    23842365        ;
     
    23922373
    23932374designator:
    2394         '.' no_attr_identifier                                                          // C99, field name
     2375        '.' identifier                                                                          // C99, field name
    23952376                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    23962377        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    24372418
    24382419type_parameter:                                                                                 // CFA
    2439         type_class no_attr_identifier_or_type_name
     2420        type_class identifier_or_type_name
    24402421                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    24412422          type_initializer_opt assertion_list_opt
     
    24702451
    24712452assertion:                                                                                              // CFA
    2472         '|' no_attr_identifier_or_type_name '(' type_list ')'
     2453        '|' identifier_or_type_name '(' type_list ')'
    24732454                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    24742455        | '|' '{' push trait_declaration_list pop '}'
     
    25072488
    25082489type_declarator_name:                                                                   // CFA
    2509         no_attr_identifier_or_type_name
     2490        identifier_or_type_name
    25102491                {
    25112492                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    25122493                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    25132494                }
    2514         | no_attr_identifier_or_type_name '(' type_parameter_list ')'
     2495        | identifier_or_type_name '(' type_parameter_list ')'
    25152496                {
    25162497                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
     
    25202501
    25212502trait_specifier:                                                                                // CFA
    2522         TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'
     2503        TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    25232504                { $$ = DeclarationNode::newTrait( $2, $4, 0 ); }
    2524         | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
     2505        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    25252506                { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
    25262507        ;
  • src/ResolvExpr/AlternativeFinder.cc

    rc60a664 r99cadc60  
    1010// Created On       : Sat May 16 23:52:08 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 21:00:56 2018
    13 // Update Count     : 35
     12// Last Modified On : Thu Jul 25 22:37:46 2019
     13// Update Count     : 37
    1414//
    1515
     
    7979                void postvisit( OffsetofExpr * offsetofExpr );
    8080                void postvisit( OffsetPackExpr * offsetPackExpr );
    81                 void postvisit( AttrExpr * attrExpr );
    8281                void postvisit( LogicalExpr * logicalExpr );
    8382                void postvisit( ConditionalExpr * conditionalExpr );
     
    14041403        }
    14051404
    1406         namespace {
    1407                 void resolveAttr( SymTab::Indexer::IdData data, const FunctionType * function, Type * argType, const TypeEnvironment &env, AlternativeFinder & finder ) {
    1408                         // assume no polymorphism
    1409                         // assume no implicit conversions
    1410                         assert( function->parameters.size() == 1 );
    1411                         PRINT(
    1412                                 std::cerr << "resolvAttr: funcDecl is ";
    1413                                 data.id->print( std::cerr );
    1414                                 std::cerr << " argType is ";
    1415                                 argType->print( std::cerr );
    1416                                 std::cerr << std::endl;
    1417                         )
    1418                         const SymTab::Indexer & indexer = finder.get_indexer();
    1419                         AltList & alternatives = finder.get_alternatives();
    1420                         if ( typesCompatibleIgnoreQualifiers( argType, function->parameters.front()->get_type(), indexer, env ) ) {
    1421                                 Cost cost = Cost::zero;
    1422                                 Expression * newExpr = data.combine( cost );
    1423                                 alternatives.push_back( Alternative{
    1424                                         new AttrExpr{ newExpr, argType->clone() }, env, OpenVarSet{},
    1425                                         AssertionList{}, Cost::zero, cost } );
    1426                                 for ( DeclarationWithType * retVal : function->returnVals ) {
    1427                                         alternatives.back().expr->result = retVal->get_type()->clone();
    1428                                 } // for
    1429                         } // if
    1430                 }
    1431         }
    1432 
    1433         void AlternativeFinder::Finder::postvisit( AttrExpr * attrExpr ) {
    1434                 // assume no 'pointer-to-attribute'
    1435                 NameExpr * nameExpr = dynamic_cast< NameExpr* >( attrExpr->get_attr() );
    1436                 assert( nameExpr );
    1437                 std::list< SymTab::Indexer::IdData > attrList;
    1438                 indexer.lookupId( nameExpr->get_name(), attrList );
    1439                 if ( attrExpr->get_isType() || attrExpr->get_expr() ) {
    1440                         for ( auto & data : attrList ) {
    1441                                 const DeclarationWithType * id = data.id;
    1442                                 // check if the type is function
    1443                                 if ( const FunctionType * function = dynamic_cast< const FunctionType * >( id->get_type() ) ) {
    1444                                         // assume exactly one parameter
    1445                                         if ( function->parameters.size() == 1 ) {
    1446                                                 if ( attrExpr->get_isType() ) {
    1447                                                         resolveAttr( data, function, attrExpr->get_type(), env, altFinder);
    1448                                                 } else {
    1449                                                         AlternativeFinder finder( indexer, env );
    1450                                                         finder.find( attrExpr->get_expr() );
    1451                                                         for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {
    1452                                                                 if ( choice->expr->get_result()->size() == 1 ) {
    1453                                                                         resolveAttr(data, function, choice->expr->get_result(), choice->env, altFinder );
    1454                                                                 } // fi
    1455                                                         } // for
    1456                                                 } // if
    1457                                         } // if
    1458                                 } // if
    1459                         } // for
    1460                 } else {
    1461                         for ( auto & data : attrList ) {
    1462                                 Cost cost = Cost::zero;
    1463                                 Expression * newExpr = data.combine( cost );
    1464                                 alternatives.push_back( Alternative{
    1465                                         newExpr, env, OpenVarSet{}, AssertionList{}, Cost::zero, cost } );
    1466                                 renameTypes( alternatives.back().expr );
    1467                         } // for
    1468                 } // if
    1469         }
    1470 
    14711405        void AlternativeFinder::Finder::postvisit( LogicalExpr * logicalExpr ) {
    14721406                AlternativeFinder firstFinder( indexer, env );
  • src/SymTab/Demangle.cc

    rc60a664 r99cadc60  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Jul 19 12:52:41 2018
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jul 19 12:54:35 2018
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jul 30 13:46:33 2019
     13// Update Count     : 3
    1414//
    1515
     
    313313                        typeString = "_Atomic " + typeString;
    314314                } // if
    315                 if ( type->get_lvalue() ) {
    316                         // when not generating C code, print lvalue for debugging.
    317                         typeString = "lvalue " + typeString;
    318                 }
    319315        }
    320316}
  • src/SymTab/Mangler.cc

    rc60a664 r99cadc60  
    1010// Created On       : Sun May 17 21:40:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 25 15:49:26 2017
    13 // Update Count     : 23
     12// Last Modified On : Tue Jul 30 13:46:10 2019
     13// Update Count     : 26
    1414//
    1515#include "Mangler.h"
     
    377377                                        mangleName << Encoding::qualifiers.at(Type::Mutex);
    378378                                } // if
    379                                 if ( type->get_lvalue() ) {
    380                                         // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues
    381                                         mangleName << Encoding::qualifiers.at(Type::Lvalue);
    382                                 }
    383 
    384379                                if ( inFunctionType ) {
    385380                                        // turn off inFunctionType so that types can be differentiated for nested qualifiers
     
    724719                                mangleName << Encoding::qualifiers.at(Type::Mutex);
    725720                        } // if
    726                         if ( type->is_lvalue() ) {
    727                                 // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues
    728                                 mangleName << Encoding::qualifiers.at(Type::Lvalue);
    729                         }
    730 
    731721                        if ( inFunctionType ) {
    732722                                // turn off inFunctionType so that types can be differentiated for nested qualifiers
  • src/SynTree/Expression.cc

    rc60a664 r99cadc60  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 19 18:10:55 2019
    13 // Update Count     : 60
     12// Last Modified On : Thu Jul 25 22:21:48 2019
     13// Update Count     : 61
    1414//
    1515
     
    249249        os << "Offset pack expression on ";
    250250        type->print(os, indent+1);
    251         Expression::print( os, indent );
    252 }
    253 
    254 AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :
    255                 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
    256 }
    257 
    258 AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :
    259                 Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    260 }
    261 
    262 AttrExpr::AttrExpr( const AttrExpr & other ) :
    263                 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    264 }
    265 
    266 AttrExpr::~AttrExpr() {
    267         delete attr;
    268         delete expr;
    269         delete type;
    270 }
    271 
    272 void AttrExpr::print( std::ostream & os, Indenter indent) const {
    273         os << "Attr ";
    274         attr->print( os, indent+1);
    275         if ( isType || expr ) {
    276                 os << "applied to: ";
    277                 if (isType) type->print(os, indent+1);
    278                 else expr->print(os, indent+1);
    279         } // if
    280251        Expression::print( os, indent );
    281252}
  • src/SynTree/Expression.h

    rc60a664 r99cadc60  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb 18 18:29:51 2019
    13 // Update Count     : 49
     12// Last Modified On : Thu Jul 25 22:21:44 2019
     13// Update Count     : 50
    1414//
    1515
     
    463463};
    464464
    465 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    466 class AttrExpr : public Expression {
    467   public:
    468         Expression * attr;
    469         Expression * expr;
    470         Type * type;
    471         bool isType;
    472 
    473         AttrExpr(Expression * attr, Expression * expr );
    474         AttrExpr( const AttrExpr & other );
    475         AttrExpr( Expression * attr, Type * type );
    476         virtual ~AttrExpr();
    477 
    478         Expression * get_attr() const { return attr; }
    479         void set_attr( Expression * newValue ) { attr = newValue; }
    480         Expression * get_expr() const { return expr; }
    481         void set_expr( Expression * newValue ) { expr = newValue; }
    482         Type * get_type() const { return type; }
    483         void set_type( Type * newValue ) { type = newValue; }
    484         bool get_isType() const { return isType; }
    485         void set_isType( bool newValue ) { isType = newValue; }
    486 
    487         virtual AttrExpr * clone() const override { return new AttrExpr( * this ); }
    488         virtual void accept( Visitor & v ) override { v.visit( this ); }
    489         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    490         virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    491         virtual void print( std::ostream & os, Indenter indent = {} ) const override;
    492 };
    493 
    494465/// LogicalExpr represents a short-circuit boolean expression (&& or ||)
    495466class LogicalExpr : public Expression {
  • src/SynTree/Mutator.h

    rc60a664 r99cadc60  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:31:00 2017
    13 // Update Count     : 16
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 25 22:37:46 2019
     13// Update Count     : 17
    1414//
    1515#pragma once
     
    7474        virtual Expression * mutate( OffsetofExpr * offsetofExpr ) = 0;
    7575        virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) = 0;
    76         virtual Expression * mutate( AttrExpr * attrExpr ) = 0;
    7776        virtual Expression * mutate( LogicalExpr * logicalExpr ) = 0;
    7877        virtual Expression * mutate( ConditionalExpr * conditionalExpr ) = 0;
  • src/SynTree/SynTree.h

    rc60a664 r99cadc60  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:54:00 2017
    13 // Update Count     : 11
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 25 22:37:45 2019
     13// Update Count     : 12
    1414//
    1515
     
    7979class OffsetofExpr;
    8080class OffsetPackExpr;
    81 class AttrExpr;
    8281class LogicalExpr;
    8382class ConditionalExpr;
  • src/SynTree/Visitor.h

    rc60a664 r99cadc60  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:28:00 2017
    13 // Update Count     : 13
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 25 22:21:49 2019
     13// Update Count     : 14
    1414//
    1515
     
    123123        virtual void visit( OffsetPackExpr * node ) { visit( const_cast<const OffsetPackExpr *>(node) ); }
    124124        virtual void visit( const OffsetPackExpr * offsetPackExpr ) = 0;
    125         virtual void visit( AttrExpr * node ) { visit( const_cast<const AttrExpr *>(node) ); }
    126         virtual void visit( const AttrExpr * attrExpr ) = 0;
    127125        virtual void visit( LogicalExpr * node ) { visit( const_cast<const LogicalExpr *>(node) ); }
    128126        virtual void visit( const LogicalExpr * logicalExpr ) = 0;
Note: See TracChangeset for help on using the changeset viewer.