Changeset 10a9479d for src


Ignore:
Timestamp:
Nov 23, 2024, 8:28:37 PM (14 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
956b389
Parents:
b006c51e (diff), de7b7a5 (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:
29 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    rb006c51e r10a9479d  
    330330enum GeneratedFlag { ExplicitCast, GeneratedCast };
    331331
     332/// Even within the basic cast expression there are variants:
     333/// CCast - C-Style Cast: A backwards compatable cast from C.
     334/// CoerceCast - Coercion Cast: Change the type without changing the value.
     335/// ReturnCast - Ascription Cast: Requires the given expression result type.
     336enum CastKind { CCast, CoerceCast, ReturnCast };
     337
    332338/// A type cast, e.g. `(int)e`
    333339class CastExpr final : public Expr {
     
    336342        GeneratedFlag isGenerated;
    337343
    338         enum CastKind {
    339                 Default, // C
    340                 Coerce, // reinterpret cast
    341                 Return  // overload selection
    342         };
    343 
    344         CastKind kind = Default;
     344        CastKind kind = CCast;
    345345
    346346        CastExpr( const CodeLocation & loc, const Expr * a, const Type * to,
    347                 GeneratedFlag g = GeneratedCast, CastKind kind = Default ) : Expr( loc, to ), arg( a ), isGenerated( g ), kind( kind ) {}
     347                GeneratedFlag g = GeneratedCast, CastKind kind = CCast ) : Expr( loc, to ), arg( a ), isGenerated( g ), kind( kind ) {}
    348348        /// Cast-to-void
    349         CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast, CastKind kind = Default );
     349        CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast, CastKind kind = CCast );
    350350
    351351        /// Wrap a cast expression around an existing expression (always generated)
  • src/AST/Pass.hpp

    rb006c51e r10a9479d  
    327327/// The Pass template handles what *before* and *after* means automatically
    328328template< template<class...> class container_t = std::list >
    329 struct WithStmtsToAdd {
     329struct WithStmtsToAddX {
    330330        container_t< ptr<Stmt> > stmtsToAddBefore;
    331331        container_t< ptr<Stmt> > stmtsToAddAfter;
    332332};
     333
     334struct WithStmtsToAdd : public WithStmtsToAddX<> {};
    333335
    334336/// Used if visitor requires added declarations before or after the current node.
    335337/// The Pass template handles what *before* and *after* means automatically
    336338template< template<class...> class container_t = std::list >
    337 struct WithDeclsToAdd {
     339struct WithDeclsToAddX {
    338340        container_t< ptr<Decl> > declsToAddBefore;
    339341        container_t< ptr<Decl> > declsToAddAfter;
    340342};
     343
     344struct WithDeclsToAdd : public WithDeclsToAddX<> {};
    341345
    342346/// Use if visitation should stop at certain levels
  • src/CodeGen/CodeGenerator.cpp

    rb006c51e r10a9479d  
    680680        extension( expr );
    681681        output << "(";
    682         if ( expr->result->isVoid() ) {
    683                 output << "(void)";
    684         } else {
    685                 output << "(";
     682        switch ( expr->kind ) {
     683        case ast::CCast:
     684                if ( expr->result->isVoid() ) {
     685                        output << "(void)";
     686                } else {
     687                        output << "(";
     688                        output << genType( expr->result, "", options );
     689                        output << ")";
     690                }
     691                break;
     692        case ast::CoerceCast:
     693                assertf( ast::CoerceCast != expr->kind, "Coercion cast is not implemented." );
     694                // And likely shouldn't reach code generation when it is implemented.
     695                break;
     696        case ast::ReturnCast:
     697                // This should be invisible in the resulting C code.
     698                // Can we insert a check here?
     699                //assert( ResolvExpr::typesCompatable(???) );
     700                if ( options.genC ) break;
     701                output << "(return ";
    686702                output << genType( expr->result, "", options );
    687703                output << ")";
     704                break;
    688705        }
    689706        expr->arg->accept( *visitor );
  • src/Concurrency/Actors.cpp

    rb006c51e r10a9479d  
    194194// collects data needed for next pass that does the circular defn resolution
    195195//     for message send operators (via table above)
    196 struct GenFuncsCreateTables : public ast::WithDeclsToAdd<> {
     196struct GenFuncsCreateTables : public ast::WithDeclsToAdd {
    197197        unordered_set<const StructDecl *> & actorStructDecls;
    198198        unordered_set<const StructDecl *>  & messageStructDecls;
     
    451451// separate pass is needed since this pass resolves circular defn issues
    452452// generates the forward declarations of the send operator for actor routines
    453 struct FwdDeclOperator : public ast::WithDeclsToAdd<> {
     453struct FwdDeclOperator : public ast::WithDeclsToAdd {
    454454        unordered_set<const StructDecl *> & actorStructDecls;
    455455        unordered_set<const StructDecl *>  & messageStructDecls;
  • src/Concurrency/Corun.cpp

    rb006c51e r10a9479d  
    2525namespace Concurrency {
    2626
    27 struct CorunKeyword : public WithDeclsToAdd<>, public WithStmtsToAdd<> {
     27struct CorunKeyword : public WithDeclsToAdd, public WithStmtsToAdd {
    2828        UniqueName CorunFnNamer = "__CFA_corun_lambda_"s;
    2929        UniqueName CoforFnNamer = "__CFA_cofor_lambda_"s;
  • src/Concurrency/Keywords.cpp

    rb006c51e r10a9479d  
    117117
    118118// --------------------------------------------------------------------------
    119 struct ConcurrentSueKeyword : public ast::WithDeclsToAdd<> {
     119struct ConcurrentSueKeyword : public ast::WithDeclsToAdd {
    120120        ConcurrentSueKeyword(
    121121                std::string&& type_name, std::string&& field_name,
     
    639639// --------------------------------------------------------------------------
    640640struct SuspendKeyword final :
    641                 public ast::WithStmtsToAdd<>, public ast::WithGuards {
     641                public ast::WithStmtsToAdd, public ast::WithGuards {
    642642        SuspendKeyword() = default;
    643643        virtual ~SuspendKeyword() = default;
     
    860860
    861861// --------------------------------------------------------------------------
    862 struct MutexKeyword final : public ast::WithDeclsToAdd<> {
     862struct MutexKeyword final : public ast::WithDeclsToAdd {
    863863        const ast::FunctionDecl * postvisit( const ast::FunctionDecl * decl );
    864864        void postvisit( const ast::StructDecl * decl );
  • src/Concurrency/Waituntil.cpp

    rb006c51e r10a9479d  
    13981398// To add the predicates at global scope we need to do it in a second pass
    13991399// Predicates are added after "struct select_node { ... };"
    1400 class AddPredicateDecls final : public WithDeclsToAdd<> {
     1400class AddPredicateDecls final : public WithDeclsToAdd {
    14011401        vector<FunctionDecl *> & satFns;
    14021402        const StructDecl * selectNodeDecl = nullptr;
  • src/ControlStruct/ExceptDecl.cpp

    rb006c51e r10a9479d  
    401401}
    402402
    403 struct ExceptDeclCore : public ast::WithDeclsToAdd<> {
     403struct ExceptDeclCore : public ast::WithDeclsToAdd {
    404404        ast::StructDecl const * transformExcept( ast::StructDecl const * decl );
    405405        ast::ObjectDecl const * transformVTable(
  • src/GenPoly/Box.cpp

    rb006c51e r10a9479d  
    5555/// Adds layout-generation functions to polymorphic types.
    5656struct LayoutFunctionBuilder final :
    57                 public ast::WithDeclsToAdd<>,
     57                public ast::WithDeclsToAdd,
    5858                public ast::WithShortCircuiting,
    5959                public ast::WithVisitorRef<LayoutFunctionBuilder> {
     
    344344                public ast::WithGuards,
    345345                public ast::WithShortCircuiting,
    346                 public ast::WithStmtsToAdd<>,
     346                public ast::WithStmtsToAdd,
    347347                public ast::WithVisitorRef<CallAdapter> {
    348348        CallAdapter();
     
    15751575struct PolyGenericCalculator final :
    15761576                public ast::WithConstTypeSubstitution,
    1577                 public ast::WithDeclsToAdd<>,
     1577                public ast::WithDeclsToAdd,
    15781578                public ast::WithGuards,
    1579                 public ast::WithStmtsToAdd<>,
     1579                public ast::WithStmtsToAdd,
    15801580                public ast::WithVisitorRef<PolyGenericCalculator> {
    15811581        PolyGenericCalculator();
  • src/GenPoly/InstantiateGeneric.cpp

    rb006c51e r10a9479d  
    277277                public ast::WithVisitorRef<FixDtypeStatic>,
    278278                public ast::WithShortCircuiting,
    279                 public ast::WithStmtsToAdd<> {
     279                public ast::WithStmtsToAdd {
    280280        ast::ApplicationExpr const * previsit( ast::ApplicationExpr const * expr );
    281281        void previsit( ast::AddressExpr const * expr );
     
    421421                public ast::WithCodeLocation,
    422422                public ast::WithConstTypeSubstitution,
    423                 public ast::WithDeclsToAdd<>,
     423                public ast::WithDeclsToAdd,
    424424                public ast::WithGuards,
    425425                public ast::WithVisitorRef<GenericInstantiator>
  • src/GenPoly/Lvalue.cpp

    rb006c51e r10a9479d  
    8585struct ReferenceConversions final :
    8686                public ast::WithConstTranslationUnit,
    87                 public ast::WithGuards, public ast::WithStmtsToAdd<> {
     87                public ast::WithGuards, public ast::WithStmtsToAdd {
    8888        ast::Expr const * postvisit( ast::CastExpr const * expr );
    8989        ast::Expr const * postvisit( ast::AddressExpr const * expr );
     
    316316                        Warning::RvalueToReferenceConversion, toCString( expr->arg ) );
    317317
     318                // allowing conversion in the rvalue to const ref case
     319                // use the referenced-to type to create temp variables
     320                ast::Type const * targetType = dstType;
     321                for (int i = 0; i < diff; ++i) targetType = (strict_dynamic_cast<ast::ReferenceType const *>(targetType))->base;
     322
    318323                static UniqueName tmpNamer( "__ref_tmp_" );
    319324                ast::ObjectDecl * tmp = new ast::ObjectDecl( expr->arg->location,
    320325                        tmpNamer.newName(),
    321                         ast::deepCopy( expr->arg->result ),
     326                        // ast::deepCopy( expr->arg->result ),
     327                        ast::deepCopy (targetType),
    322328                        new ast::SingleInit( expr->arg->location, expr->arg ) );
    323329                PRINT( std::cerr << "make tmp: " << tmp << std::endl; )
     
    359365                        ret = new ast::AddressExpr( ret->location, ret );
    360366                }
    361                 if ( expr->arg->get_lvalue() &&
    362                                 !ResolvExpr::typesCompatible(
    363                                         srcType,
    364                                         strict_dynamic_cast<ast::ReferenceType const *>( dstType )->base ) ) {
    365                         // Must keep cast if cast-to type is different from the actual type.
     367                // Must keep cast if types are different.
     368                if ( !ResolvExpr::typesCompatible(
     369                                srcType,
     370                                strict_dynamic_cast<ast::ReferenceType const *>( dstType )->base ) ) {
    366371                        return ast::mutate_field( expr, &ast::CastExpr::arg, ret );
    367372                }
     
    377382                }
    378383                // Must keep cast if types are different.
    379                 if ( !ResolvExpr::typesCompatibleIgnoreQualifiers(
     384                if ( !ResolvExpr::typesCompatible(
    380385                                dstType->stripReferences(),
    381386                                srcType->stripReferences() ) ) {
     
    390395        } else {
    391396                assert( 0 == diff );
    392                 // Remove useless generated casts.
    393                 if ( expr->isGenerated == ast::GeneratedFlag::GeneratedCast &&
    394                                 ResolvExpr::typesCompatible(
     397                // Must keep cast if types are different. (Or it is explicit.)
     398                if ( ast::ExplicitCast == expr->isGenerated ||
     399                                !ResolvExpr::typesCompatible(
    395400                                        expr->result,
    396401                                        expr->arg->result ) ) {
    397                         PRINT(
    398                                 std::cerr << "types are compatible, removing cast: " << expr << '\n';
    399                                 std::cerr << "-- " << expr->result << '\n';
    400                                 std::cerr << "-- " << expr->arg->result << std::endl;
    401                         )
    402                         auto argAsEnum = expr->arg.as<ast::EnumInstType>();
    403                         auto resultAsEnum = expr->result.as<ast::EnumInstType>();
    404                         if (argAsEnum && resultAsEnum) {
    405                                 if (argAsEnum->base->name != resultAsEnum->base->name) {
    406                                         return expr;
    407                                 }
    408                         }
    409                         return ast::mutate_field( expr->arg.get(),
    410                                         &ast::Expr::env, expr->env.get() );
    411                 }
    412                 return expr;
     402                        return expr;
     403                }
     404                PRINT(
     405                        std::cerr << "types are compatible, removing cast: " << expr << '\n';
     406                        std::cerr << "-- " << expr->result << '\n';
     407                        std::cerr << "-- " << expr->arg->result << std::endl;
     408                )
     409                return ast::mutate_field( expr->arg.get(),
     410                                &ast::Expr::env, expr->env.get() );
    413411        }
    414412}
     
    505503}
    506504
     505/// Recursively move an address expression underneath casts. Casts are not
     506/// lvalue expressions in C but are sometimes considered as such in Cforall,
     507/// (passes like InstantiateGeneric can add them.) - &(int) => (int*)&
     508ast::Expr const * moveAddressUnderCast( ast::AddressExpr const * expr ) {
     509        if ( !dynamic_cast<ast::CastExpr const *>( expr->arg.get() ) ) {
     510                return expr;
     511        }
     512        auto mutExpr = ast::mutate( expr );
     513        auto mutCast = strict_dynamic_cast<ast::CastExpr *>(
     514                        ast::mutate( mutExpr->arg.release() ) );
     515        mutExpr->arg = mutCast->arg;
     516        mutCast->arg = moveAddressUnderCast( mutExpr );
     517        mutCast->result = new ast::PointerType( mutCast->result );
     518        return mutCast;
     519}
     520
    507521ast::Expr const * CollapseAddressDeref::postvisit(
    508522                ast::AddressExpr const * expr ) {
     
    516530                        return ret;
    517531                }
    518         } else if ( auto cast = dynamic_cast<ast::CastExpr const *>( arg ) ) {
    519                 // Need to move cast to pointer type out a level since address of
    520                 // pointer is not valid C code (can be introduced in prior passes,
    521                 // e.g., InstantiateGeneric)
    522                 if ( ast::getPointerBase( cast->result ) ) {
    523                         auto mutExpr = ast::mutate( expr );
    524                         auto mutCast = strict_dynamic_cast<ast::CastExpr *>(
    525                                         ast::mutate( mutExpr->arg.release() ) );
    526                         mutExpr->arg = mutCast->arg;
    527                         mutCast->arg = mutExpr;
    528                         mutCast->result = new ast::PointerType( mutCast->result );
    529                         return mutCast;
    530                 }
     532        } else {
     533                return moveAddressUnderCast( expr );
    531534        }
    532535        return expr;
  • src/GenPoly/Specialize.cpp

    rb006c51e r10a9479d  
    3030struct SpecializeCore final :
    3131                public ast::WithConstTypeSubstitution,
    32                 public ast::WithDeclsToAdd<>,
     32                public ast::WithDeclsToAdd,
    3333                public ast::WithVisitorRef<SpecializeCore> {
    3434        std::string paramPrefix = "_p";
  • src/InitTweak/FixInit.cpp

    rb006c51e r10a9479d  
    105105/// generate/resolve copy construction expressions for each, and generate/resolve destructors for both
    106106/// arguments and return value temporaries
    107 struct ResolveCopyCtors final : public ast::WithGuards, public ast::WithStmtsToAdd<>, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithVisitorRef<ResolveCopyCtors>, public ast::WithConstTranslationUnit {
     107struct ResolveCopyCtors final : public ast::WithGuards, public ast::WithStmtsToAdd, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithVisitorRef<ResolveCopyCtors>, public ast::WithConstTranslationUnit {
    108108        const ast::Expr * postvisit( const ast::ImplicitCopyCtorExpr * impCpCtorExpr );
    109109        const ast::StmtExpr * previsit( const ast::StmtExpr * stmtExpr );
     
    177177/// insert destructor calls at the appropriate places.  must happen before CtorInit nodes are removed
    178178/// (currently by FixInit)
    179 struct InsertDtors final : public ObjDeclCollector, public ast::WithStmtsToAdd<> {
     179struct InsertDtors final : public ObjDeclCollector, public ast::WithStmtsToAdd {
    180180        InsertDtors( ast::Pass<LabelFinder> & finder ) : finder( finder ), labelVars( finder.core.vars ) {}
    181181
     
    194194
    195195/// expand each object declaration to use its constructor after it is declared.
    196 struct FixInit : public ast::WithStmtsToAdd<> {
     196struct FixInit : public ast::WithStmtsToAdd {
    197197        static void fixInitializers( ast::TranslationUnit &translationUnit );
    198198
     
    230230
    231231/// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument
    232 struct FixCtorExprs final : public ast::WithDeclsToAdd<>, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithConstTranslationUnit {
     232struct FixCtorExprs final : public ast::WithDeclsToAdd, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithConstTranslationUnit {
    233233        const ast::Expr * postvisit( const ast::ConstructorExpr * ctorExpr );
    234234};
  • src/InitTweak/GenInit.cpp

    rb006c51e r10a9479d  
    4646        // Outer pass finds declarations, for their type could wrap a type that needs hoisting
    4747        struct HoistArrayDimension_NoResolve final :
    48                         public ast::WithDeclsToAdd<>, public ast::WithShortCircuiting,
     48                        public ast::WithDeclsToAdd, public ast::WithShortCircuiting,
    4949                        public ast::WithGuards, public ast::WithConstTranslationUnit,
    5050                        public ast::WithVisitorRef<HoistArrayDimension_NoResolve>,
     
    205205
    206206        struct ReturnFixer final :
    207                         public ast::WithStmtsToAdd<>, ast::WithGuards, ast::WithShortCircuiting {
     207                        public ast::WithStmtsToAdd, ast::WithGuards, ast::WithShortCircuiting {
    208208                void previsit( const ast::FunctionDecl * decl );
    209209                const ast::ReturnStmt * previsit( const ast::ReturnStmt * stmt );
  • src/Parser/ExpressionNode.cpp

    rb006c51e r10a9479d  
    652652                DeclarationNode * decl_node,
    653653                ExpressionNode * expr_node,
    654                 ast::CastExpr::CastKind kind ) {
     654                ast::CastKind kind ) {
    655655        ast::Type * targetType = maybeMoveBuildType( decl_node );
    656656        if ( dynamic_cast<ast::VoidType *>( targetType ) ) {
  • src/Parser/ExpressionNode.hpp

    rb006c51e r10a9479d  
    6969ast::DimensionExpr * build_dimensionref( const CodeLocation &, const std::string * name );
    7070
    71 ast::Expr * build_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node, ast::CastExpr::CastKind kind = ast::CastExpr::Default );
     71ast::Expr * build_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node, ast::CastKind kind = ast::CCast );
    7272ast::Expr * build_keyword_cast( const CodeLocation &, ast::AggregateDecl::Aggregate target, ExpressionNode * expr_node );
    7373ast::Expr * build_virtual_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node );
  • src/Parser/parser.yy

    rb006c51e r10a9479d  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 13 12:18:15 2024
    13 // Update Count     : 6845
     12// Last Modified On : Fri Nov 15 15:01:33 2024
     13// Update Count     : 6915
    1414//
    1515
     
    2424// the grammar.
    2525
    26 // The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
    27 //
    28 //   designation with '=' (use ':' instead)
    29 //
    30 // This incompatibility is discussed in detail before the "designation" grammar rule.  Most of the syntactic extensions
    31 // from ANSI90 to ANSI11 C are marked with the comment "C99/C11".
     26// The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed.  Most of the syntactic extensions from
     27// ANSI90 to ANSI11 C are marked with the comment "C99/C11".
    3228
    3329// This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions. All of the
     
    983979                { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
    984980        | '(' RETURN type_no_function ')' cast_expression       // CFA
    985                 { $$ = new ExpressionNode( build_cast( yylloc, $3, $5, ast::CastExpr::Return ) ); }
     981                { $$ = new ExpressionNode( build_cast( yylloc, $3, $5, ast::ReturnCast ) ); }
    986982        | '(' COERCE type_no_function ')' cast_expression       // CFA
    987983                { SemanticError( yylloc, "Coerce cast is currently unimplemented." ); $$ = nullptr; }
     
    11701166                // comma_expression in cfa_identifier_parameter_array and cfa_abstract_array
    11711167        '[' ',' ']'
    1172                 { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); }
     1168                // { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); }
     1169                { SemanticError( yylloc, "Empty tuple is meaningless." ); $$ = nullptr; }
    11731170        | '[' assignment_expression ',' ']'
    11741171                { $$ = new ExpressionNode( build_tuple( yylloc, $2 ) ); }
     
    12241221        | DIRECTIVE
    12251222                { $$ = new StatementNode( build_directive( yylloc, $1 ) ); }
     1223//      | attribute ';'
     1224//              { $$ = new StatementNode( $1 ); }
    12261225        ;
    12271226
     
    20572056        | cfa_abstract_tuple identifier_or_type_name asm_name_opt
    20582057                { $$ = $1->addName( $2 )->addAsmName( $3 ); }
    2059         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name asm_name_opt
    2060                 { $$ = $2->addQualifiers( $1 )->addName( $3 )->addAsmName( $4 ); }
     2058        | multi_array_dimension cfa_abstract_tuple identifier_or_type_name asm_name_opt
     2059                { $$ = $2->addNewArray( $1 )->addName( $3 )->addAsmName( $4 ); }
     2060        | multi_array_dimension type_qualifier_list cfa_abstract_tuple identifier_or_type_name asm_name_opt
     2061                { $$ = $3->addNewArray( $1 )->addQualifiers( $2 )->addName( $4 )->addAsmName( $5 ); }
    20612062
    20622063                // [ int s, int t ];                    // declare s and t
     
    42234224        cfa_identifier_parameter_ptr
    42244225        | cfa_identifier_parameter_array
     4226        | type_qualifier_list cfa_identifier_parameter_array
     4227                { $$ = $2->addQualifiers( $1 ); }
    42254228        ;
    42264229
     
    42464249        '[' ']' type_specifier_nobody
    42474250                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     4251        | '[' ']' cfa_abstract_tuple
     4252                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    42484253        | cfa_array_parameter_1st_dimension type_specifier_nobody
     4254                { $$ = $2->addNewArray( $1 ); }
     4255        | cfa_array_parameter_1st_dimension cfa_abstract_tuple
    42494256                { $$ = $2->addNewArray( $1 ); }
    42504257        | '[' ']' multi_array_dimension type_specifier_nobody
    42514258                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     4259        | '[' ']' multi_array_dimension cfa_abstract_tuple
     4260                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    42524261        | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody
    42534262                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     4263        | cfa_array_parameter_1st_dimension multi_array_dimension cfa_abstract_tuple
     4264                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
    42544265        | multi_array_dimension type_specifier_nobody
     4266                { $$ = $2->addNewArray( $1 ); }
     4267        | multi_array_dimension cfa_abstract_tuple
    42554268                { $$ = $2->addNewArray( $1 ); }
    42564269
  • src/ResolvExpr/CandidateFinder.cpp

    rb006c51e r10a9479d  
    12201220                        finder.allowVoid = true;
    12211221                }
    1222                 if ( castExpr->kind == ast::CastExpr::Return ) {
     1222                if ( ast::ReturnCast == castExpr->kind ) {
    12231223                        finder.strictMode = true;
    12241224                        finder.find( castExpr->arg, ResolveMode::withAdjustment() );
  • src/ResolvExpr/ConversionCost.cpp

    rb006c51e r10a9479d  
    250250                        newSrc = new ast::BasicType( ast::BasicKind::UnsignedInt );
    251251                }
     252                if (dstAsRef->base->is_const() ) {
     253                        auto cvtCost = conversionCost(newSrc, dstAsRef->base, srcIsLvalue, symtab, env) ;
     254                        if (cvtCost == Cost::zero) { // exact match, may use a lvalue src
     255                                if ( srcIsLvalue ) {
     256                                        if ( src->qualifiers == dstAsRef->base->qualifiers ) {
     257                                                return Cost::reference;
     258                                        } else if ( src->qualifiers < dstAsRef->base->qualifiers ) {
     259                                                return Cost::safe;
     260                                        } else {
     261                                                return Cost::unsafe;
     262                                        }
     263                                }
     264                                else {
     265                                        return Cost::reference;
     266                                }
     267                        }
     268                        else { // not exact match, conversion is needed so lvalueness of src does not matter
     269                                return cvtCost + Cost::reference;
     270                        }
     271                }
    252272                if ( typesCompatibleIgnoreQualifiers( newSrc, dstAsRef->base, env ) ) {
    253273                        if ( srcIsLvalue ) {
     
    259279                                        return Cost::unsafe;
    260280                                }
    261                         } else if ( dstAsRef->base->is_const() ) {
    262                                 return Cost::safe;
    263                         } else {
     281                        } else { // rvalue-to-NC-ref conversion
    264282                                return Cost::unsafe;
    265283                        }
  • src/ResolvExpr/Resolver.cpp

    rb006c51e r10a9479d  
    201201                                && typesCompatible( castExpr->arg->result, castExpr->result )
    202202                        ) {
    203                                 auto argAsEnum = castExpr->arg.as<ast::EnumInstType>();
    204                                 auto resultAsEnum = castExpr->result.as<ast::EnumInstType>();
    205                                 if (argAsEnum && resultAsEnum) {
    206                                         if (argAsEnum->base->name != resultAsEnum->base->name) {
    207                                                 std::cerr << "Enum Cast: " << argAsEnum->base->name << " to " << resultAsEnum->base->name << std::endl;
    208                                                 return castExpr;
    209                                         }
     203                                ast::EnumInstType const * arg, * result;
     204                                if ( ( result = castExpr->result.as<ast::EnumInstType>() ) &&
     205                                                ( arg = castExpr->arg.as<ast::EnumInstType>() ) &&
     206                                                arg->base->name != result->base->name) {
     207                                        return castExpr;
    210208                                }
    211209                                // generated cast is the same type as its argument, remove it after keeping env
     
    377375: public ast::WithSymbolTable, public ast::WithGuards,
    378376  public ast::WithVisitorRef<Resolver>, public ast::WithShortCircuiting,
    379   public ast::WithStmtsToAdd<> {
     377  public ast::WithStmtsToAdd {
    380378
    381379        ast::ptr< ast::Type > functionReturn = nullptr;
  • src/Tuples/TupleExpansion.cpp

    rb006c51e r10a9479d  
    2828};
    2929
    30 struct UniqueExprExpander final : public ast::WithDeclsToAdd<> {
     30struct UniqueExprExpander final : public ast::WithDeclsToAdd {
    3131        const ast::Expr * postvisit( const ast::UniqueExpr * unqExpr );
    3232        // Not a vector, because they may not be adding in increasing order.
     
    3737struct TupleMainExpander final :
    3838                public ast::WithCodeLocation,
    39                 public ast::WithDeclsToAdd<>,
     39                public ast::WithDeclsToAdd,
    4040                public ast::WithGuards,
    4141                public ast::WithVisitorRef<TupleMainExpander> {
  • src/Validate/Autogen.cpp

    rb006c51e r10a9479d  
    5050// --------------------------------------------------------------------------
    5151struct AutogenerateRoutines final :
    52                 public ast::WithDeclsToAdd<>,
     52                public ast::WithDeclsToAdd,
    5353                public ast::WithShortCircuiting {
    5454        void previsit( const ast::EnumDecl * enumDecl );
  • src/Validate/CompoundLiteral.cpp

    rb006c51e r10a9479d  
    2727
    2828struct CompoundLiteral final :
    29                 public ast::WithDeclsToAdd<> {
     29                public ast::WithDeclsToAdd {
    3030        ast::Storage::Classes storageClasses;
    3131
  • src/Validate/HoistStruct.cpp

    rb006c51e r10a9479d  
    6868 */
    6969struct HoistStructCore final :
    70                 public ast::WithDeclsToAdd<>, public ast::WithGuards {
     70                public ast::WithDeclsToAdd, public ast::WithGuards {
    7171        ast::StructDecl const * previsit( ast::StructDecl const * decl );
    7272        ast::StructDecl const * postvisit( ast::StructDecl const * decl );
  • src/Validate/HoistTypeDecls.cpp

    rb006c51e r10a9479d  
    2222namespace {
    2323
    24 struct HoistTypeDecls final : public ast::WithDeclsToAdd<> {
     24struct HoistTypeDecls final : public ast::WithDeclsToAdd {
    2525        void previsit( ast::SizeofExpr const * );
    2626        void previsit( ast::AlignofExpr const * );
  • src/Validate/ImplementEnumFunc.cpp

    rb006c51e r10a9479d  
    472472
    473473struct ImplementEnumFunc final :
    474                 public ast::WithDeclsToAdd<>, public ast::WithShortCircuiting {
     474                public ast::WithDeclsToAdd, public ast::WithShortCircuiting {
    475475        void previsit(const ast::EnumDecl* enumDecl);
    476476        void previsit(const ast::FunctionDecl* functionDecl);
  • src/Validate/LinkInstanceTypes.cpp

    rb006c51e r10a9479d  
    2727struct LinkTypesCore : public WithNoIdSymbolTable,
    2828                public ast::WithCodeLocation,
    29                 public ast::WithDeclsToAdd<>,
     29                public ast::WithDeclsToAdd,
    3030                public ast::WithGuards,
    3131                public ast::WithShortCircuiting,
  • src/Validate/ReplaceTypedef.cpp

    rb006c51e r10a9479d  
    2828struct ReplaceTypedefCore final :
    2929                public ast::WithCodeLocation,
    30                 public ast::WithDeclsToAdd<>,
     30                public ast::WithDeclsToAdd,
    3131                public ast::WithGuards,
    3232                public ast::WithShortCircuiting,
  • src/Virtual/VirtualDtor.cpp

    rb006c51e r10a9479d  
    119119// collects data needed for next pass that does the circular defn resolution
    120120//     for dtor setters and delete fns (via table above)
    121 struct GenFuncsCreateTables : public ast::WithDeclsToAdd<> {
     121struct GenFuncsCreateTables : public ast::WithDeclsToAdd {
    122122        unordered_map<const StructDecl *, CtorDtor> & structDecls;
    123123        CtorDtorTable & torDecls;
     
    351351// separate pass is needed since  __CFA_set_dtor needs to be defined after
    352352//   the last dtor defn which is found in prior pass
    353 struct GenSetDtor : public ast::WithDeclsToAdd<> {
     353struct GenSetDtor : public ast::WithDeclsToAdd {
    354354        unordered_map<const StructDecl *, CtorDtor> & structDecls; // set of decls that inherit from virt dtor
    355355        CtorDtorTable & torDecls;
Note: See TracChangeset for help on using the changeset viewer.