Changeset e5d9274 for src


Ignore:
Timestamp:
Jun 2, 2022, 3:11:21 PM (3 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
ced5e2a
Parents:
015925a (diff), fc134a48 (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:
7 added
1 deleted
41 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r015925a re5d9274  
    1010// Created On       : Wed May 15 17:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Created On       : Tue Nov 30 14:23:00 2021
    13 // Update Count     : 7
     12// Created On       : Wed May 18 13:56:00 2022
     13// Update Count     : 8
    1414//
    1515
     
    2121
    2222#include "Copy.hpp"                // for shallowCopy
    23 #include "Eval.hpp"                // for call
    2423#include "GenericSubstitution.hpp"
    2524#include "LinkageSpec.hpp"
     
    6766// --- UntypedExpr
    6867
     68bool UntypedExpr::get_lvalue() const {
     69        std::string fname = InitTweak::getFunctionName( this );
     70        return lvalueFunctionNames.count( fname );
     71}
     72
    6973UntypedExpr * UntypedExpr::createDeref( const CodeLocation & loc, const Expr * arg ) {
    7074        assert( arg );
    7175
    72         UntypedExpr * ret = call( loc, "*?", arg );
     76        UntypedExpr * ret = createCall( loc, "*?", { arg } );
    7377        if ( const Type * ty = arg->result ) {
    7478                const Type * base = InitTweak::getPointerBase( ty );
     
    8791}
    8892
    89 bool UntypedExpr::get_lvalue() const {
    90         std::string fname = InitTweak::getFunctionName( this );
    91         return lvalueFunctionNames.count( fname );
    92 }
    93 
    9493UntypedExpr * UntypedExpr::createAssign( const CodeLocation & loc, const Expr * lhs, const Expr * rhs ) {
    9594        assert( lhs && rhs );
    9695
    97         UntypedExpr * ret = call( loc, "?=?", lhs, rhs );
     96        UntypedExpr * ret = createCall( loc, "?=?", { lhs, rhs } );
    9897        if ( lhs->result && rhs->result ) {
    9998                // if both expressions are typed, assumes that this assignment is a C bitwise assignment,
     
    102101        }
    103102        return ret;
     103}
     104
     105UntypedExpr * UntypedExpr::createCall( const CodeLocation & loc,
     106                const std::string & name, std::vector<ptr<Expr>> && args ) {
     107        return new UntypedExpr( loc,
     108                        new NameExpr( loc, name ), std::move( args ) );
    104109}
    105110
  • src/AST/Expr.hpp

    r015925a re5d9274  
    230230        /// Creates a new assignment expression
    231231        static UntypedExpr * createAssign( const CodeLocation & loc, const Expr * lhs, const Expr * rhs );
     232        /// Creates a new call of a variable.
     233        static UntypedExpr * createCall( const CodeLocation & loc,
     234                const std::string & name, std::vector<ptr<Expr>> && args );
    232235
    233236        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/module.mk

    r015925a re5d9274  
    2929        AST/DeclReplacer.cpp \
    3030        AST/DeclReplacer.hpp \
    31         AST/Eval.hpp \
    3231        AST/Expr.cpp \
    3332        AST/Expr.hpp \
  • src/CodeGen/CodeGenerator.cc

    r015925a re5d9274  
    12381238} // namespace CodeGen
    12391239
    1240 
    1241 unsigned Indenter::tabsize = 2;
    1242 
    1243 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
    1244         if ( node ) {
    1245                 node->print( out );
    1246         } else {
    1247                 out << "nullptr";
    1248         }
    1249         return out;
    1250 }
    1251 
    12521240// Local Variables: //
    12531241// tab-width: 4 //
  • src/CodeGen/FixMain.cc

    r015925a re5d9274  
    4949
    5050}
    51 
    52         bool FixMain::replace_main = false;
    5351
    5452        template<typename container>
  • src/CodeGen/GenType.cc

    r015925a re5d9274  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May  1 15:24:00 2019
    13 // Update Count     : 23
     12// Last Modified On : Fri May 20 11:18:00 2022
     13// Update Count     : 24
    1414//
    1515#include "GenType.h"
     
    5050                void postvisit( TraitInstType * inst );
    5151                void postvisit( TypeofType * typeof );
     52                void postvisit( VTableType * vtable );
    5253                void postvisit( QualifiedType * qualType );
    5354
     
    259260                        if ( options.genC ) {
    260261                                typeString = "enum " + typeString;
    261                         } 
    262                 } 
     262                        }
     263                }
    263264                handleQualifiers( enumInst );
    264265        }
    265266
    266267        void GenType::postvisit( TypeInstType * typeInst ) {
     268                assertf( ! options.genC, "Type instance types should not reach code generation." );
    267269                typeString = typeInst->name + " " + typeString;
    268270                handleQualifiers( typeInst );
     
    320322        }
    321323
     324        void GenType::postvisit( VTableType * vtable ) {
     325                assertf( ! options.genC, "Virtual table types should not reach code generation." );
     326                std::ostringstream os;
     327                os << "vtable(" << genType( vtable->base, "", options ) << ") " << typeString;
     328                typeString = os.str();
     329                handleQualifiers( vtable );
     330        }
     331
    322332        void GenType::postvisit( QualifiedType * qualType ) {
    323333                assertf( ! options.genC, "Qualified types should not reach code generation." );
  • src/CodeGen/LinkOnce.cc

    r015925a re5d9274  
    5353                                new ConstantExpr( Constant::from_string( section_name ) )
    5454                        );
     55
     56                        // Unconditionnaly add "visibility(default)" to anything with gnu.linkonce
     57                        // visibility is a mess otherwise
     58                        attributes.push_back(new Attribute("visibility", {new ConstantExpr( Constant::from_string( "default" ) )}));
     59
    5560                }
    5661                visit_children = false;
  • src/CodeGen/module.mk

    r015925a re5d9274  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Dec 14 07:29:42 2019
    14 ## Update Count     : 4
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 14:26:00 2022
     14## Update Count     : 5
    1515###############################################################################
    1616
    17 #SRC +=  ArgTweak/Rewriter.cc \
    18 #       ArgTweak/Mutate.cc
     17SRC_CODEGEN = \
     18        CodeGen/FixMain2.cc \
     19        CodeGen/FixMain.h \
     20        CodeGen/OperatorTable.cc \
     21        CodeGen/OperatorTable.h
    1922
    20 SRC_CODEGEN = \
     23SRC += $(SRC_CODEGEN) \
    2124        CodeGen/CodeGenerator.cc \
    2225        CodeGen/CodeGenerator.h \
     26        CodeGen/Generate.cc \
     27        CodeGen/Generate.h \
    2328        CodeGen/FixMain.cc \
    24         CodeGen/FixMain.h \
     29        CodeGen/FixNames.cc \
     30        CodeGen/FixNames.h \
    2531        CodeGen/GenType.cc \
    2632        CodeGen/GenType.h \
    2733        CodeGen/LinkOnce.cc \
    2834        CodeGen/LinkOnce.h \
    29         CodeGen/OperatorTable.cc \
    30         CodeGen/OperatorTable.h \
    3135        CodeGen/Options.h
    3236
    33 SRC += $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/Generate.h CodeGen/FixNames.cc CodeGen/FixNames.h
    3437SRCDEMANGLE += $(SRC_CODEGEN)
  • src/CodeTools/ResolvProtoDump.cc

    r015925a re5d9274  
    304304
    305305                        // replace enums with int
    306                         void previsit( EnumInstType* ) { ss << (int)BasicType::SignedInt; }
     306                        void previsit( EnumInstType* ) {
     307                                // TODO: add the meaningful representation of typed int
     308                                ss << (int)BasicType::SignedInt;
     309                        }
    307310
    308311                        void previsit( TypeInstType* vt ) {
  • src/Common/Indenter.h

    r015925a re5d9274  
    1010// Created On       : Fri Jun 30 16:55:23 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug 11 11:15:00 2017
    13 // Update Count     : 1
     12// Last Modified On : Fri May 13 14:10:00 2022
     13// Update Count     : 2
    1414//
    1515
    16 #ifndef INDENTER_H
    17 #define INDENTER_H
     16#pragma once
     17
     18#include <ostream>
    1819
    1920struct Indenter {
     
    3738        return out << std::string(indent.indent * indent.amt, ' ');
    3839}
    39 
    40 #endif // INDENTER_H
  • src/Common/ResolvProtoDump.cpp

    r015925a re5d9274  
    227227        }
    228228
    229         void previsit( const ast::EnumInstType * ) {
     229        void previsit( const ast::EnumInstType * enumInst) {
     230                // TODO: Add the meaningful text representation of typed enum
    230231                ss << (int)ast::BasicType::SignedInt;
    231232        }
  • src/Common/module.mk

    r015925a re5d9274  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Sep 27 11:06:38 2016
    14 ## Update Count     : 4
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 14:27:00 2022
     14## Update Count     : 5
    1515###############################################################################
    1616
    1717SRC_COMMON = \
    18       Common/Assert.cc \
    19       Common/CodeLocation.h \
    20       Common/CodeLocationTools.hpp \
    21       Common/CodeLocationTools.cpp \
    22       Common/CompilerError.h \
    23       Common/Debug.h \
    24       Common/DeclStats.hpp \
    25       Common/DeclStats.cpp \
    26       Common/ErrorObjects.h \
    27       Common/Eval.cc \
    28       Common/Examine.cc \
    29       Common/Examine.h \
    30       Common/FilterCombos.h \
    31       Common/Indenter.h \
    32       Common/PassVisitor.cc \
    33       Common/PassVisitor.h \
    34       Common/PassVisitor.impl.h \
    35       Common/PassVisitor.proto.h \
    36       Common/PersistentMap.h \
    37       Common/ResolvProtoDump.hpp \
    38       Common/ResolvProtoDump.cpp \
    39       Common/ScopedMap.h \
    40       Common/SemanticError.cc \
    41       Common/SemanticError.h \
    42       Common/Stats.h \
    43       Common/Stats/Base.h \
    44       Common/Stats/Counter.cc \
    45       Common/Stats/Counter.h \
    46       Common/Stats/Heap.cc \
    47       Common/Stats/Heap.h \
    48       Common/Stats/ResolveTime.cc \
    49       Common/Stats/ResolveTime.h \
    50       Common/Stats/Stats.cc \
    51       Common/Stats/Time.cc \
    52       Common/Stats/Time.h \
    53       Common/UnimplementedError.h \
    54       Common/UniqueName.cc \
    55       Common/UniqueName.h \
    56       Common/utility.h \
    57       Common/VectorMap.h
     18        Common/Assert.cc \
     19        Common/CodeLocation.h \
     20        Common/CodeLocationTools.hpp \
     21        Common/CodeLocationTools.cpp \
     22        Common/CompilerError.h \
     23        Common/Debug.h \
     24        Common/DeclStats.hpp \
     25        Common/DeclStats.cpp \
     26        Common/ErrorObjects.h \
     27        Common/Eval.cc \
     28        Common/Examine.cc \
     29        Common/Examine.h \
     30        Common/FilterCombos.h \
     31        Common/Indenter.h \
     32        Common/Indenter.cc \
     33        Common/PassVisitor.cc \
     34        Common/PassVisitor.h \
     35        Common/PassVisitor.impl.h \
     36        Common/PassVisitor.proto.h \
     37        Common/PersistentMap.h \
     38        Common/ResolvProtoDump.hpp \
     39        Common/ResolvProtoDump.cpp \
     40        Common/ScopedMap.h \
     41        Common/SemanticError.cc \
     42        Common/SemanticError.h \
     43        Common/Stats.h \
     44        Common/Stats/Base.h \
     45        Common/Stats/Counter.cc \
     46        Common/Stats/Counter.h \
     47        Common/Stats/Heap.cc \
     48        Common/Stats/Heap.h \
     49        Common/Stats/ResolveTime.cc \
     50        Common/Stats/ResolveTime.h \
     51        Common/Stats/Stats.cc \
     52        Common/Stats/Time.cc \
     53        Common/Stats/Time.h \
     54        Common/UnimplementedError.h \
     55        Common/UniqueName.cc \
     56        Common/UniqueName.h \
     57        Common/utility.h \
     58        Common/VectorMap.h
    5859
    59 SRC += $(SRC_COMMON) Common/DebugMalloc.cc
     60SRC += $(SRC_COMMON) \
     61        Common/DebugMalloc.cc
     62
    6063SRCDEMANGLE += $(SRC_COMMON)
  • src/Concurrency/module.mk

    r015925a re5d9274  
    1010## Author           : Thierry Delisle
    1111## Created On       : Mon Mar 13 12:48:40 2017
    12 ## Last Modified By :
    13 ## Last Modified On :
    14 ## Update Count     : 0
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 13:28:00 2022
     14## Update Count     : 1
    1515###############################################################################
    1616
    17 SRC_CONCURRENCY = \
     17SRC += \
    1818        Concurrency/KeywordsNew.cpp \
    19         Concurrency/Keywords.cc
    20 
    21 SRC += $(SRC_CONCURRENCY) \
     19        Concurrency/Keywords.cc \
    2220        Concurrency/Keywords.h \
    2321        Concurrency/Waitfor.cc \
    2422        Concurrency/Waitfor.h
    25 
    26 SRCDEMANGLE += $(SRC_CONCURRENCY)
    27 
  • src/ControlStruct/ExceptDecl.cc

    r015925a re5d9274  
    99// Author           : Henry Xue
    1010// Created On       : Tue Jul 20 04:10:50 2021
    11 // Last Modified By : Henry Xue
    12 // Last Modified On : Tue Aug 03 10:42:26 2021
    13 // Update Count     : 4
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed May 25 16:43:00 2022
     13// Update Count     : 5
    1414//
    1515
     
    3939}
    4040
    41 TypeInstType * makeExceptInstType(
    42         const std::string & exceptionName,
    43         const std::list< Expression *> & parameters
    44 ) {
    45         TypeInstType * exceptInstType = new TypeInstType(
     41StructInstType * makeExceptInstType(
     42        const std::string & exceptionName,
     43        const std::list< Expression *> & parameters
     44) {
     45        StructInstType * exceptInstType = new StructInstType(
    4646                noQualifiers,
    47                 exceptionName,
    48                 false
     47                exceptionName
    4948        );
    5049        cloneAll( parameters, exceptInstType->parameters );
     
    151150                nullptr,
    152151                new PointerType( noQualifiers,
    153                         new TypeInstType( Type::Const, "__cfavir_type_info", false ) ),
     152                        new StructInstType( Type::Const, "__cfavir_type_info" ) ),
    154153                nullptr
    155154        ) );
     
    257256        const std::string & exceptionName,
    258257        const std::list< TypeDecl *> & forallClause,
    259         const std::list< Expression *> & parameters, 
     258        const std::list< Expression *> & parameters,
    260259        const std::list< Declaration *> & members
    261260) {
     
    302301ObjectDecl * ehmExternVtable(
    303302        const std::string & exceptionName,
    304         const std::list< Expression *> & parameters, 
     303        const std::list< Expression *> & parameters,
    305304        const std::string & tableName
    306305) {
     
    457456}
    458457
     458class VTableCore : public WithDeclsToAdd {
     459public:
     460        // Remove any remaining vtable type nodes in the tree.
     461        Type * postmutate( VTableType * vtableType );
     462};
     463
     464Type * VTableCore::postmutate( VTableType * vtableType ) {
     465        auto inst = strict_dynamic_cast<ReferenceToType *>( vtableType->base );
     466
     467        std::string vtableName = Virtual::vtableTypeName( inst->name );
     468        StructInstType * newType = new StructInstType( noQualifiers, vtableName );
     469        cloneAll( inst->parameters, newType->parameters );
     470
     471        delete vtableType;
     472        return newType;
     473}
     474
    459475void translateExcept( std::list< Declaration *> & translationUnit ) {
    460476        PassVisitor<ExceptDeclCore> translator;
    461477        mutateAll( translationUnit, translator );
    462 }
    463 
    464 }
     478        PassVisitor<VTableCore> typeTranslator;
     479        mutateAll( translationUnit, typeTranslator );
     480}
     481
     482}
  • src/ControlStruct/module.mk

    r015925a re5d9274  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Jan 29 12:04:19 2022
    14 ## Update Count     : 7
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 14:30:00 2022
     14## Update Count     : 8
    1515###############################################################################
    1616
    17 SRC_CONTROLSTRUCT = \
     17SRC += \
    1818        ControlStruct/ExceptDecl.cc \
    1919        ControlStruct/ExceptDecl.h \
     20        ControlStruct/ExceptTranslateNew.cpp \
     21        ControlStruct/ExceptTranslate.cc \
     22        ControlStruct/ExceptTranslate.h \
    2023        ControlStruct/FixLabels.cpp \
    2124        ControlStruct/FixLabels.hpp \
     
    3740        ControlStruct/Mutate.h
    3841
    39 SRC += $(SRC_CONTROLSTRUCT) \
    40         ControlStruct/ExceptTranslateNew.cpp \
    41         ControlStruct/ExceptTranslate.cc \
    42         ControlStruct/ExceptTranslate.h
    43 
    44 SRCDEMANGLE += $(SRC_CONTROLSTRUCT)
    45 
  • src/GenPoly/Lvalue.cc

    r015925a re5d9274  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 23:14:38 2019
    13 // Update Count     : 7
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon May 16 14:09:00 2022
     13// Update Count     : 8
    1414//
    1515
     
    125125        } // namespace
    126126
    127         static bool referencesEliminated = false;
    128         // used by UntypedExpr::createDeref to determine whether result type of dereference should be ReferenceType or value type.
    129         bool referencesPermissable() {
    130                 return ! referencesEliminated;
    131         }
     127        // Stored elsewhere (Lvalue2, initially false).
     128        extern bool referencesEliminated;
    132129
    133130        void convertLvalue( std::list< Declaration* > & translationUnit ) {
  • src/GenPoly/module.mk

    r015925a re5d9274  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jun  1 17:52:30 2015
    14 ## Update Count     : 1
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 14:31:00 2022
     14## Update Count     : 2
    1515###############################################################################
    1616
    17 SRC += GenPoly/Box.cc \
    18        GenPoly/Box.h \
    19        GenPoly/ErasableScopedMap.h \
    20        GenPoly/FindFunction.cc \
    21        GenPoly/FindFunction.h \
    22        GenPoly/GenPoly.cc \
    23        GenPoly/GenPoly.h \
    24        GenPoly/InstantiateGeneric.cc \
    25        GenPoly/InstantiateGeneric.h \
    26        GenPoly/Lvalue.cc \
    27        GenPoly/Lvalue.h \
    28        GenPoly/ScopedSet.h \
    29        GenPoly/ScrubTyVars.cc \
    30        GenPoly/ScrubTyVars.h \
    31        GenPoly/Specialize.cc \
    32        GenPoly/Specialize.h
     17SRC_GENPOLY = \
     18        GenPoly/GenPoly.cc \
     19        GenPoly/GenPoly.h \
     20        GenPoly/Lvalue2.cc \
     21        GenPoly/Lvalue.h
    3322
    34 SRCDEMANGLE += GenPoly/GenPoly.cc GenPoly/GenPoly.h GenPoly/Lvalue.cc GenPoly/Lvalue.h
     23SRC += $(SRC_GENPOLY) \
     24        GenPoly/Box.cc \
     25        GenPoly/Box.h \
     26        GenPoly/ErasableScopedMap.h \
     27        GenPoly/FindFunction.cc \
     28        GenPoly/FindFunction.h \
     29        GenPoly/InstantiateGeneric.cc \
     30        GenPoly/InstantiateGeneric.h \
     31        GenPoly/Lvalue.cc \
     32        GenPoly/ScopedSet.h \
     33        GenPoly/ScrubTyVars.cc \
     34        GenPoly/ScrubTyVars.h \
     35        GenPoly/Specialize.cc \
     36        GenPoly/Specialize.h
    3537
     38SRCDEMANGLE += $(SRC_GENPOLY)
  • src/InitTweak/FixInitNew.cpp

    r015925a re5d9274  
    454454
    455455                auto expr = new ast::ImplicitCopyCtorExpr( appExpr->location, mutExpr );
    456                 // Move the type substitution to the new top-level, if it is attached to the appExpr.
    457                 // Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion.
    458                 // The substitution is needed to obtain the type of temporary variables so that copy constructor
    459                 // calls can be resolved.
     456                // Move the type substitution to the new top-level. The substitution
     457                // is needed to obtain the type of temporary variables so that copy
     458                // constructor calls can be resolved.
    460459                assert( typeSubs );
    461                 // assert (mutExpr->env);
    462460                expr->env = tmp;
    463                 // mutExpr->env = nullptr;
    464                 //std::swap( expr->env, appExpr->env );
    465461                return expr;
    466462        }
    467463
    468464        void ResolveCopyCtors::previsit(const ast::Expr * expr) {
    469                 if (expr->env) {
    470                         GuardValue(env);
    471                         GuardValue(envModified);
    472                         env = expr->env->clone();
    473                         envModified = false;
    474                 }
     465                if ( nullptr == expr->env ) {
     466                        return;
     467                }
     468                GuardValue( env ) = expr->env->clone();
     469                GuardValue( envModified ) = false;
    475470        }
    476471
    477472        const ast::Expr * ResolveCopyCtors::postvisit(const ast::Expr * expr) {
    478                 if (expr->env) {
    479                         if (envModified) {
    480                                 auto mutExpr = mutate(expr);
    481                                 mutExpr->env = env;
    482                                 return mutExpr;
    483                         }
    484                         else {
    485                                 // env was not mutated, skip and delete the shallow copy
    486                                 delete env;
    487                                 return expr;
    488                         }
    489                 }
    490                 else {
     473                // No local environment, skip.
     474                if ( nullptr == expr->env ) {
     475                        return expr;
     476                // Environment was modified, mutate and replace.
     477                } else if ( envModified ) {
     478                        auto mutExpr = mutate(expr);
     479                        mutExpr->env = env;
     480                        return mutExpr;
     481                // Environment was not mutated, delete the shallow copy before guard.
     482                } else {
     483                        delete env;
    491484                        return expr;
    492485                }
     
    497490        const ast::Expr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, const ast::ObjectDecl * var, const ast::Expr * cpArg ) {
    498491                assert( var );
    499                 assert (var->isManaged());
    500                 assert (!cpArg || cpArg->isManaged());
     492                assert( var->isManaged() );
     493                assert( !cpArg || cpArg->isManaged() );
    501494                // arrays are not copy constructed, so this should always be an ExprStmt
    502495                ast::ptr< ast::Stmt > stmt = genCtorDtor(var->location, fname, var, cpArg );
     
    504497                auto exprStmt = stmt.strict_as<ast::ImplicitCtorDtorStmt>()->callStmt.strict_as<ast::ExprStmt>();
    505498                ast::ptr<ast::Expr> untyped = exprStmt->expr; // take ownership of expr
    506                 // exprStmt->expr = nullptr;
    507499
    508500                // resolve copy constructor
     
    516508                        env->add( *resolved->env );
    517509                        envModified = true;
    518                         // delete resolved->env;
    519510                        auto mut = mutate(resolved.get());
    520511                        assertf(mut == resolved.get(), "newly resolved expression must be unique");
    521512                        mut->env = nullptr;
    522513                } // if
    523                 // delete stmt;
    524514                if ( auto assign = resolved.as<ast::TupleAssignExpr>() ) {
    525515                        // fix newly generated StmtExpr
  • src/InitTweak/GenInit.cc

    r015925a re5d9274  
    368368
    369369        struct ReturnFixer_New final :
    370                         public ast::WithStmtsToAdd<>, ast::WithGuards {
     370                        public ast::WithStmtsToAdd<>, ast::WithGuards, ast::WithShortCircuiting {
    371371                void previsit( const ast::FunctionDecl * decl );
    372372                const ast::ReturnStmt * previsit( const ast::ReturnStmt * stmt );
     
    376376
    377377        void ReturnFixer_New::previsit( const ast::FunctionDecl * decl ) {
     378                if (decl->linkage == ast::Linkage::Intrinsic) visit_children = false;
    378379                GuardValue( funcDecl ) = decl;
    379380        }
  • src/InitTweak/module.mk

    r015925a re5d9274  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Fri May 13 11:36:24 2016
    14 ## Update Count     : 3
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 14:31:00 2022
     14## Update Count     : 4
    1515###############################################################################
    1616
    17 SRC += \
    18         InitTweak/FixGlobalInit.cc \
    19         InitTweak/FixGlobalInit.h \
    20         InitTweak/FixInit.cc \
    21         InitTweak/FixInit.h \
    22         InitTweak/GenInit.cc \
    23         InitTweak/GenInit.h \
    24         InitTweak/InitTweak.cc \
    25         InitTweak/InitTweak.h \
    26         InitTweak/FixInitNew.cpp
    27 
    28 SRCDEMANGLE += \
     17SRC_INITTWEAK = \
    2918        InitTweak/GenInit.cc \
    3019        InitTweak/GenInit.h \
     
    3221        InitTweak/InitTweak.h
    3322
     23SRC += $(SRC_INITTWEAK) \
     24        InitTweak/FixGlobalInit.cc \
     25        InitTweak/FixGlobalInit.h \
     26        InitTweak/FixInit.cc \
     27        InitTweak/FixInit.h \
     28        InitTweak/FixInitNew.cpp
     29
     30SRCDEMANGLE += $(SRC_INITTWEAK)
  • src/Parser/parser.yy

    r015925a re5d9274  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May  4 17:22:48 2022
    13 // Update Count     : 5279
     12// Last Modified On : Sat May 14 09:16:22 2022
     13// Update Count     : 5401
    1414//
    1515
     
    5454#include "Common/SemanticError.h"                                               // error_str
    5555#include "Common/utility.h"                                                             // for maybeMoveBuild, maybeBuild, CodeLo...
     56
     57#include "SynTree/Attribute.h"     // for Attribute
    5658
    5759extern DeclarationNode * parseTree;
     
    9395} // appendStr
    9496
    95 DeclarationNode * distAttr( DeclarationNode * specifier, DeclarationNode * declList ) {
    96         // distribute declaration_specifier across all declared variables, e.g., static, const, __attribute__.
    97         DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( specifier );
     97DeclarationNode * distAttr( DeclarationNode * typeSpec, DeclarationNode * declList ) {
     98        // distribute declaration_specifier across all declared variables, e.g., static, const, but not __attribute__.
     99        assert( declList );
     100//      printf( "distAttr1 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout );
     101        DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( typeSpec );
     102//      printf( "distAttr2 cl %p\n", cl ); cl->type->print( std::cout );
     103//      cl->type->aggregate.name = cl->type->aggInst.aggregate->aggregate.name;
     104
    98105        for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) {
    99106                cl->cloneBaseType( cur );
    100107        } // for
    101108        declList->addType( cl );
     109//      printf( "distAttr3 declList %p\n", declList ); declList->print( std::cout, 0 );
    102110        return declList;
    103111} // distAttr
     
    171179                if ( ! ( typeSpec->type && (typeSpec->type->kind == TypeData::Aggregate || typeSpec->type->kind == TypeData::Enum) ) ) {
    172180                        stringstream ss;
    173                         typeSpec->type->print( ss );
     181                        // printf( "fieldDecl1 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout );
    174182                        SemanticWarning( yylloc, Warning::SuperfluousDecl, ss.str().c_str() );
    175183                        return nullptr;
    176184                } // if
     185                // printf( "fieldDecl2 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout );
    177186                fieldList = DeclarationNode::newName( nullptr );
    178187        } // if
    179         return distAttr( typeSpec, fieldList );                         // mark all fields in list
     188//      return distAttr( typeSpec, fieldList );                         // mark all fields in list
     189
     190        // printf( "fieldDecl3 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout, 0 );
     191        DeclarationNode * temp = distAttr( typeSpec, fieldList );                               // mark all fields in list
     192        // printf( "fieldDecl4 temp %p\n", temp ); temp->print( std::cout, 0 );
     193        return temp;
    180194} // fieldDecl
    181195
     
    16201634declaration:                                                                                    // old & new style declarations
    16211635        c_declaration ';'
     1636                {
     1637                        // printf( "C_DECLARATION1 %p %s\n", $$, $$->name ? $$->name->c_str() : "(nil)" );
     1638                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     1639                        //   printf( "\tattr %s\n", attr->name.c_str() );
     1640                        // } // for
     1641                }
    16221642        | cfa_declaration ';'                                                           // CFA
    16231643        | static_assert                                                                         // C11
     
    18251845        basic_type_specifier
    18261846        | sue_type_specifier
     1847                {
     1848                        // printf( "sue_type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     1849                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     1850                        //   printf( "\tattr %s\n", attr->name.c_str() );
     1851                        // } // for
     1852                }
    18271853        | type_type_specifier
    18281854        ;
     
    20412067sue_declaration_specifier:                                                              // struct, union, enum + storage class + type specifier
    20422068        sue_type_specifier
     2069                {
     2070                        // printf( "sue_declaration_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     2071                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2072                        //   printf( "\tattr %s\n", attr->name.c_str() );
     2073                        // } // for
     2074                }
    20432075        | declaration_qualifier_list sue_type_specifier
    20442076                { $$ = $2->addQualifiers( $1 ); }
     
    20512083sue_type_specifier:                                                                             // struct, union, enum + type specifier
    20522084        elaborated_type
     2085                {
     2086                        // printf( "sue_type_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     2087                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2088                        //   printf( "\tattr %s\n", attr->name.c_str() );
     2089                        // } // for
     2090                }
    20532091        | type_qualifier_list
    20542092                { if ( $1->type != nullptr && $1->type->forall ) forall = true; } // remember generic type
     
    21232161elaborated_type:                                                                                // struct, union, enum
    21242162        aggregate_type
     2163                {
     2164                        // printf( "elaborated_type %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     2165                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2166                        //   printf( "\tattr %s\n", attr->name.c_str() );
     2167                        // } // for
     2168                }
    21252169        | enum_type
    21262170        ;
     
    21422186                }
    21432187          '{' field_declaration_list_opt '}' type_parameters_opt
    2144                 { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); }
     2188                {
     2189                        // printf( "aggregate_type1 %s\n", $3.str->c_str() );
     2190                        // if ( $2 )
     2191                        //      for ( Attribute * attr: reverseIterate( $2->attributes ) ) {
     2192                        //              printf( "copySpecifiers12 %s\n", attr->name.c_str() );
     2193                        //      } // for
     2194                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     2195                        // printf( "aggregate_type2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     2196                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2197                        //      printf( "aggregate_type3 %s\n", attr->name.c_str() );
     2198                        // } // for
     2199                }
    21452200        | aggregate_key attribute_list_opt TYPEDEFname          // unqualified type name
    21462201                {
     
    21502205          '{' field_declaration_list_opt '}' type_parameters_opt
    21512206                {
     2207                        // printf( "AGG3\n" );
    21522208                        DeclarationNode::newFromTypedef( $3 );
    21532209                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     
    21602216          '{' field_declaration_list_opt '}' type_parameters_opt
    21612217                {
     2218                        // printf( "AGG4\n" );
    21622219                        DeclarationNode::newFromTypeGen( $3, nullptr );
    21632220                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     
    22362293field_declaration:
    22372294        type_specifier field_declaring_list_opt ';'
    2238                 { $$ = fieldDecl( $1, $2 ); }
     2295                {
     2296                        // printf( "type_specifier1 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     2297                        $$ = fieldDecl( $1, $2 );
     2298                        // printf( "type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
     2299                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2300                        //   printf( "\tattr %s\n", attr->name.c_str() );
     2301                        // } // for
     2302                }
    22392303        | EXTENSION type_specifier field_declaring_list_opt ';' // GCC
    22402304                { $$ = fieldDecl( $2, $3 ); distExt( $$ ); }
     
    28452909        // empty
    28462910                { $$ = nullptr; forall = false; }
    2847         | WITH '(' tuple_expression_list ')'
    2848                 { $$ = $3; forall = false; }
     2911        | WITH '(' tuple_expression_list ')' attribute_list_opt
     2912                {
     2913                        $$ = $3; forall = false;
     2914                        if ( $5 ) {
     2915                                SemanticError( yylloc, "Attributes cannot be associated with function body. Move attribute(s) before \"with\" clause." );
     2916                                $$ = nullptr;
     2917                        } // if
     2918                }
    28492919        ;
    28502920
  • src/ResolvExpr/AlternativeFinder.cc

    r015925a re5d9274  
    4242#include "SymTab/Indexer.h"        // for Indexer
    4343#include "SymTab/Mangler.h"        // for Mangler
    44 #include "SymTab/Validate.h"       // for validateType
     44#include "SymTab/ValidateType.h"   // for validateType
    4545#include "SynTree/Constant.h"      // for Constant
    4646#include "SynTree/Declaration.h"   // for DeclarationWithType, TypeDecl, Dec...
  • src/ResolvExpr/CandidateFinder.cpp

    r015925a re5d9274  
    899899
    900900                                                if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);
     901                                                else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) {
     902                                                        const ast::EnumDecl * enumDecl = enumInst->base;
     903                                                        if ( const ast::Type* enumType = enumDecl->base ) {
     904                                                                // instance of enum (T) is a instance of type (T)
     905                                                                funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type));
     906                                                        } else {
     907                                                                // instance of an untyped enum is techically int
     908                                                                funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type));
     909                                                        }
     910                                                }
    901911                                                else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type));
    902912                                        }
     
    918928
    919929                        // find function operators
    920                         ast::ptr< ast::Expr > opExpr = new ast::NameExpr{ untypedExpr->location, "?()" };
     930                        ast::ptr< ast::Expr > opExpr = new ast::NameExpr{ untypedExpr->location, "?()" }; // ??? why not ?{}
    921931                        CandidateFinder opFinder( context, tenv );
    922932                        // okay if there aren't any function operations
  • src/ResolvExpr/CommonType.cc

    r015925a re5d9274  
    497497                                result = new BasicType( basicType->tq | otherBasic->tq, newType );
    498498                        } // if
    499                 } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType * >( type2 ) || dynamic_cast< OneType * >( type2 ) ) {
     499                } else if ( dynamic_cast< ZeroType * >( type2 ) || dynamic_cast< OneType * >( type2 ) ) {
    500500                        // use signed int in lieu of the enum/zero/one type
    501501                        BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ BasicType::SignedInt ];
     
    503503                                result = new BasicType( basicType->tq | type2->tq, newType );
    504504                        } // if
    505                 } // if
     505                } else if ( const EnumInstType * enumInst = dynamic_cast< const EnumInstType * > ( type2 ) ) {
     506                        const EnumDecl* enumDecl = enumInst->baseEnum;
     507                        if ( const Type* baseType = enumDecl->base ) {
     508                                result = baseType->clone();
     509                        } else {
     510                                BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ BasicType::SignedInt ];
     511                                if ( ( ( newType == basicType->get_kind() && basicType->tq >= type2->tq ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->tq <= type2->tq ) || widenSecond ) ) {
     512                                        result = new BasicType( basicType->tq | type2->tq, newType );
     513                                } // if
     514                        }
     515                }
    506516        }
    507517
     
    691701                                }
    692702                        } else if (
    693                                 dynamic_cast< const ast::EnumInstType * >( type2 )
    694                                 || dynamic_cast< const ast::ZeroType * >( type2 )
     703                                dynamic_cast< const ast::ZeroType * >( type2 )
    695704                                || dynamic_cast< const ast::OneType * >( type2 )
    696705                        ) {
     
    705714                                        result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };
    706715                                }
     716                        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
     717                                #warning remove casts when `commonTypes` moved to new AST
     718                                const ast::EnumDecl* enumDecl = enumInst->base;
     719                                if ( enumDecl->base ) {
     720                                        result = enumDecl->base.get();
     721                                } else {
     722                                        ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)ast::BasicType::SignedInt ];
     723                                        if (
     724                                                ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     725                                                        || widen.first )
     726                                                && ( ( kind != basic->kind && basic->qualifiers <= type2->qualifiers )
     727                                                        || widen.second )
     728                                        ) {
     729                                                result = new ast::BasicType{ kind, basic->qualifiers | type2->qualifiers };
     730                                        }
     731                                }
    707732                        }
    708733                }
     
    723748                        result = voidPtr;
    724749                        add_qualifiers( result, oPtr->qualifiers );
     750                }
     751
     752                // For a typed enum, we want to unify type1 with the base type of the enum
     753                bool tryResolveWithTypedEnum( const ast::Type * type1 ) {
     754                        if (auto enumInst = dynamic_cast<const ast::EnumInstType *> (type2) ) {
     755                                ast::AssertionSet have, need; // unused
     756                                ast::OpenVarSet newOpen{ open };
     757                                if (enumInst->base->base
     758                                && unifyExact(type1, enumInst->base->base, tenv, need, have, newOpen, widen, symtab)) {
     759                                        result = type1;
     760                                        return true;
     761                                }
     762                        }
     763                        return false;
    725764                }
    726765
     
    768807                                result = pointer;
    769808                                add_qualifiers( result, type2->qualifiers );
    770                         }
    771                 }
    772 
    773                 void postvisit( const ast::ArrayType * ) {}
     809                        } else {
     810                                tryResolveWithTypedEnum( pointer );
     811                        }
     812                }
     813
     814                void postvisit( const ast::ArrayType * arr ) {
     815                        // xxx - does it make sense?
     816                        tryResolveWithTypedEnum( arr );
     817                }
    774818
    775819                void postvisit( const ast::ReferenceType * ref ) {
     
    810854                                result = ref;
    811855                                add_qualifiers( result, type2->qualifiers );
    812                         }
    813                 }
    814 
    815                 void postvisit( const ast::FunctionType * ) {}
    816 
    817                 void postvisit( const ast::StructInstType * ) {}
    818 
    819                 void postvisit( const ast::UnionInstType * ) {}
     856                        } else {
     857                                // xxx - does unifying a ref with typed enumInst makes sense?
     858                                if (!dynamic_cast<const ast::EnumInstType *>(type2))
     859                                        result = commonType( type2, ref, widen, symtab, tenv, open );
     860                        }
     861                }
     862
     863                void postvisit( const ast::FunctionType * func) {
     864                        tryResolveWithTypedEnum( func );
     865                }
     866
     867                void postvisit( const ast::StructInstType * inst ) {
     868                        tryResolveWithTypedEnum( inst );
     869                }
     870
     871                void postvisit( const ast::UnionInstType * inst ) {
     872                        tryResolveWithTypedEnum( inst );
     873                }
    820874
    821875                void postvisit( const ast::EnumInstType * enumInst ) {
    822                         if (
    823                                 dynamic_cast< const ast::BasicType * >( type2 )
    824                                 || dynamic_cast< const ast::ZeroType * >( type2 )
    825                                 || dynamic_cast< const ast::OneType * >( type2 )
    826                         ) {
    827                                 // reuse BasicType/EnumInstType common type by swapping
     876                        // reuse BasicType/EnumInstType common type by swapping
     877                        // xxx - is this already handled by unify?
     878                        if (!dynamic_cast<const ast::EnumInstType *>(type2))
    828879                                result = commonType( type2, enumInst, widen, symtab, tenv, open );
    829                         }
    830880                }
    831881
     
    850900                                                result = type2;
    851901                                                reset_qualifiers( result, q1 | q2 );
     902                                        } else {
     903                                                tryResolveWithTypedEnum( t1 );
    852904                                        }
    853905                                }
     
    855907                }
    856908
    857                 void postvisit( const ast::TupleType * ) {}
     909                void postvisit( const ast::TupleType * tuple) {
     910                        tryResolveWithTypedEnum( tuple );
     911                }
    858912
    859913                void postvisit( const ast::VarArgsType * ) {}
     
    861915                void postvisit( const ast::ZeroType * zero ) {
    862916                        if ( ! widen.first ) return;
    863                         if (
    864                                 dynamic_cast< const ast::BasicType * >( type2 )
    865                                 || dynamic_cast< const ast::PointerType * >( type2 )
    866                                 || dynamic_cast< const ast::EnumInstType * >( type2 )
    867                         ) {
     917                        if ( dynamic_cast< const ast::BasicType * >( type2 )
     918                                || dynamic_cast< const ast::PointerType * >( type2 ) ) {
    868919                                if ( widen.second || zero->qualifiers <= type2->qualifiers ) {
    869920                                        result = type2;
     
    873924                                result = new ast::BasicType{
    874925                                        ast::BasicType::SignedInt, zero->qualifiers | type2->qualifiers };
     926                        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
     927                                const ast::EnumDecl * enumDecl = enumInst->base;
     928                                if ( enumDecl->base ) {
     929                                        if ( tryResolveWithTypedEnum( zero ) )
     930                                                add_qualifiers( result, zero->qualifiers );
     931                                } else {
     932                                        if ( widen.second || zero->qualifiers <= type2->qualifiers ) {
     933                                                result = type2;
     934                                                add_qualifiers( result, zero->qualifiers );
     935                                        }
     936                                }
    875937                        }
    876938                }
     
    878940                void postvisit( const ast::OneType * one ) {
    879941                        if ( ! widen.first ) return;
    880                         if (
    881                                 dynamic_cast< const ast::BasicType * >( type2 )
    882                                 || dynamic_cast< const ast::EnumInstType * >( type2 )
    883                         ) {
     942                        if ( dynamic_cast< const ast::BasicType * >( type2 ) ) {
    884943                                if ( widen.second || one->qualifiers <= type2->qualifiers ) {
    885944                                        result = type2;
     
    889948                                result = new ast::BasicType{
    890949                                        ast::BasicType::SignedInt, one->qualifiers | type2->qualifiers };
     950                        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
     951                                const ast::EnumDecl * enumBase = enumInst->base;
     952                                if ( enumBase->base ) {
     953                                        if ( tryResolveWithTypedEnum( one ))
     954                                                add_qualifiers( result, one->qualifiers );
     955                                } else {
     956                                        if ( widen.second || one->qualifiers <= type2->qualifiers ) {
     957                                                result = type2;
     958                                                add_qualifiers( result, one->qualifiers );
     959                                        }
     960                                }
    891961                        }
    892962                }
  • src/ResolvExpr/ConversionCost.cc

    r015925a re5d9274  
    321321        }
    322322
     323        // refactor for code resue
     324        void ConversionCost::conversionCostFromBasicToBasic(const BasicType * src, const BasicType * dest) {
     325                int tableResult = costMatrix[ src->kind ][ dest->kind ];
     326                if ( tableResult == -1 ) {
     327                        cost = Cost::unsafe;
     328                } else {
     329                        cost = Cost::zero;
     330                        cost.incSafe( tableResult );
     331                        cost.incSign( signMatrix[ src->kind ][ dest->kind ] );
     332                } // if
     333        } // ConversionCost::conversionCostFromBasicToBasic
     334
    323335        void ConversionCost::postvisit(const BasicType * basicType) {
    324336                if ( const BasicType * destAsBasic = dynamic_cast< const BasicType * >( dest ) ) {
    325                         int tableResult = costMatrix[ basicType->kind ][ destAsBasic->kind ];
    326                         if ( tableResult == -1 ) {
    327                                 cost = Cost::unsafe;
    328                         } else {
    329                                 cost = Cost::zero;
    330                                 cost.incSafe( tableResult );
    331                                 cost.incSign( signMatrix[ basicType->kind ][ destAsBasic->kind ] );
    332                         } // if
    333                 } else if ( dynamic_cast< const EnumInstType * >( dest ) ) {
    334                         // xxx - not positive this is correct, but appears to allow casting int => enum
    335                         // TODO
    336                         EnumDecl * decl = dynamic_cast< const EnumInstType * >( dest )->baseEnum;
    337                         if ( decl->base ) {
    338                                 cost = Cost::infinity;
     337                        conversionCostFromBasicToBasic(basicType, destAsBasic);
     338                } else if ( const EnumInstType * enumInst = dynamic_cast< const EnumInstType * >( dest ) ) {
     339                        const EnumDecl * base_enum = enumInst->baseEnum;
     340                        if ( const Type * base = base_enum->base ) { // if the base enum has a base (if it is typed)
     341                                if ( const BasicType * enumBaseAstBasic = dynamic_cast< const BasicType *> (base) ) {
     342                                        conversionCostFromBasicToBasic(basicType, enumBaseAstBasic);
     343                                } else {
     344                                        cost = Cost::infinity;
     345                                } // if
    339346                        } else {
    340347                                cost = Cost::unsafe;
     
    398405        void ConversionCost::postvisit( const FunctionType * ) {}
    399406
    400         void ConversionCost::postvisit( const EnumInstType * ) {
    401                 static Type::Qualifiers q;
    402                 static BasicType integer( q, BasicType::SignedInt );
    403                 cost = costFunc( &integer, dest, srcIsLvalue, indexer, env );  // safe if dest >= int
     407        void ConversionCost::postvisit( const EnumInstType * enumInst) {
     408                const EnumDecl * enumDecl = enumInst -> baseEnum;
     409                if ( const Type * enumType = enumDecl -> base ) { // if it is a typed enum
     410                        cost = costFunc( enumType, dest, srcIsLvalue, indexer, env );
     411                } else {
     412                        static Type::Qualifiers q;
     413                        static BasicType integer( q, BasicType::SignedInt );
     414                        cost = costFunc( &integer, dest, srcIsLvalue, indexer, env );  // safe if dest >= int
     415                } // if
    404416                if ( cost < Cost::unsafe ) {
    405                         cost.incSafe();
     417                                cost.incSafe();
    406418                } // if
    407419        }
     
    604616}
    605617
     618void ConversionCost_new::conversionCostFromBasicToBasic( const ast::BasicType * src, const ast::BasicType* dest ) {
     619        int tableResult = costMatrix[ src->kind ][ dest->kind ];
     620        if ( tableResult == -1 ) {
     621                cost = Cost::unsafe;
     622        } else {
     623                cost = Cost::zero;
     624                cost.incSafe( tableResult );
     625                cost.incSign( signMatrix[ src->kind ][ dest->kind ] );
     626        }
     627}
     628
    606629void ConversionCost_new::postvisit( const ast::BasicType * basicType ) {
    607630        if ( const ast::BasicType * dstAsBasic = dynamic_cast< const ast::BasicType * >( dst ) ) {
    608                 int tableResult = costMatrix[ basicType->kind ][ dstAsBasic->kind ];
    609                 if ( tableResult == -1 ) {
    610                         cost = Cost::unsafe;
    611                 } else {
    612                         cost = Cost::zero;
    613                         cost.incSafe( tableResult );
    614                         cost.incSign( signMatrix[ basicType->kind ][ dstAsBasic->kind ] );
    615                 }
    616         } else if ( dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    617                 // xxx - not positive this is correct, but appears to allow casting int => enum
    618                 const ast::EnumDecl * decl = (dynamic_cast< const ast::EnumInstType * >( dst ))->base.get();
    619                 if ( decl->base ) {
    620                         cost = Cost::infinity;
    621                 } else {
    622                         cost = Cost::unsafe;
    623                 } // if
     631                conversionCostFromBasicToBasic( basicType, dstAsBasic );
     632        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
     633                const ast::EnumDecl * enumDecl = enumInst->base.get();
     634                if ( const ast::Type * enumType = enumDecl->base.get() ) {
     635                        if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) {
     636                                conversionCostFromBasicToBasic( basicType, enumTypeAsBasic );
     637                        } else {
     638                                cost = Cost::infinity;
     639                        }
     640                } else {
     641            cost = Cost::unsafe;
     642                }
    624643        }
    625644}
     
    673692
    674693void ConversionCost_new::postvisit( const ast::EnumInstType * enumInstType ) {
    675         (void)enumInstType;
    676         static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    677         cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     694        const ast::EnumDecl * baseEnum = enumInstType->base;
     695        if ( const ast::Type * baseType = baseEnum->base ) {
     696                cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );
     697        } else {
     698                (void)enumInstType;
     699                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
     700                cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     701        }
    678702        if ( cost < Cost::unsafe ) {
    679703                cost.incSafe();
  • src/ResolvExpr/ConversionCost.h

    r015925a re5d9274  
    6565                const TypeEnvironment &env;
    6666                CostFunction costFunc;
     67          private:
     68                // refactor for code resue
     69                void conversionCostFromBasicToBasic( const BasicType * src, const BasicType* dest );
    6770        };
    6871
     
    111114        void postvisit( const ast::ZeroType * zeroType );
    112115        void postvisit( const ast::OneType * oneType );
     116private:
     117        // refactor for code resue
     118        void conversionCostFromBasicToBasic( const ast::BasicType * src, const ast::BasicType* dest );
    113119};
    114120
  • src/SymTab/Autogen.h

    r015925a re5d9274  
    2121
    2222#include "AST/Decl.hpp"
    23 #include "AST/Eval.hpp"
    2423#include "AST/Expr.hpp"
    2524#include "AST/Init.hpp"
     
    7170        template< typename OutIter >
    7271        ast::ptr< ast::Stmt > genCall(
    73                 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 
    74                 const CodeLocation & loc, const std::string & fname, OutIter && out, 
     72                InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     73                const CodeLocation & loc, const std::string & fname, OutIter && out,
    7574                const ast::Type * type, const ast::Type * addCast, LoopDirection forward = LoopForward );
    7675
     
    128127        }
    129128
    130         /// inserts into out a generated call expression to function fname with arguments dstParam and 
     129        /// inserts into out a generated call expression to function fname with arguments dstParam and
    131130        /// srcParam. Should only be called with non-array types.
    132         /// optionally returns a statement which must be inserted prior to the containing loop, if 
     131        /// optionally returns a statement which must be inserted prior to the containing loop, if
    133132        /// there is one
    134133        template< typename OutIter >
    135         ast::ptr< ast::Stmt > genScalarCall( 
    136                 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 
    137                 const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type, 
     134        ast::ptr< ast::Stmt > genScalarCall(
     135                InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     136                const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type,
    138137                const ast::Type * addCast = nullptr
    139138        ) {
     
    153152
    154153                if ( addCast ) {
    155                         // cast to T& with qualifiers removed, so that qualified objects can be constructed and 
    156                         // destructed with the same functions as non-qualified objects. Unfortunately, lvalue 
    157                         // is considered a qualifier - for AddressExpr to resolve, its argument must have an 
     154                        // cast to T& with qualifiers removed, so that qualified objects can be constructed and
     155                        // destructed with the same functions as non-qualified objects. Unfortunately, lvalue
     156                        // is considered a qualifier - for AddressExpr to resolve, its argument must have an
    158157                        // lvalue-qualified type, so remove all qualifiers except lvalue.
    159158                        // xxx -- old code actually removed lvalue too...
    160159                        ast::ptr< ast::Type > guard = addCast;  // prevent castType from mutating addCast
    161160                        ast::ptr< ast::Type > castType = addCast;
    162                         ast::remove_qualifiers( 
    163                                 castType, 
     161                        ast::remove_qualifiers(
     162                                castType,
    164163                                ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Atomic );
    165164                        dstParam = new ast::CastExpr{ dstParam, new ast::ReferenceType{ castType } };
     
    181180
    182181                srcParam.clearArrayIndices();
    183                
     182
    184183                return listInit;
    185184        }
     
    249248        }
    250249
    251         /// Store in out a loop which calls fname on each element of the array with srcParam and 
     250        /// Store in out a loop which calls fname on each element of the array with srcParam and
    252251        /// dstParam as arguments. If forward is true, loop goes from 0 to N-1, else N-1 to 0
    253252        template< typename OutIter >
    254253        void genArrayCall(
    255                 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 
    256                 const CodeLocation & loc, const std::string & fname, OutIter && out, 
    257                 const ast::ArrayType * array, const ast::Type * addCast = nullptr, 
    258                 LoopDirection forward = LoopForward 
     254                InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     255                const CodeLocation & loc, const std::string & fname, OutIter && out,
     256                const ast::ArrayType * array, const ast::Type * addCast = nullptr,
     257                LoopDirection forward = LoopForward
    259258        ) {
    260259                static UniqueName indexName( "_index" );
     
    279278                } else {
    280279                        // generate: for ( int i = N-1; i >= 0; --i )
    281                         begin = ast::call(
    282                                 loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ) );
     280                        begin = ast::UntypedExpr::createCall( loc, "?-?",
     281                                { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } );
    283282                        end = ast::ConstantExpr::from_int( loc, 0 );
    284283                        cmp = "?>=?";
     
    286285                }
    287286
    288                 ast::ptr< ast::DeclWithType > index = new ast::ObjectDecl{ 
    289                         loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt }, 
     287                ast::ptr< ast::DeclWithType > index = new ast::ObjectDecl{
     288                        loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt },
    290289                        new ast::SingleInit{ loc, begin } };
    291290                ast::ptr< ast::Expr > indexVar = new ast::VariableExpr{ loc, index };
    292                
    293                 ast::ptr< ast::Expr > cond = ast::call( loc, cmp, indexVar, end );
    294                
    295                 ast::ptr< ast::Expr > inc = ast::call( loc, update, indexVar );
    296                
    297                 ast::ptr< ast::Expr > dstIndex = ast::call( loc, "?[?]", dstParam, indexVar );
    298                
    299                 // srcParam must keep track of the array indices to build the source parameter and/or
     291
     292                ast::ptr< ast::Expr > cond = ast::UntypedExpr::createCall(
     293                        loc, cmp, { indexVar, end } );
     294
     295                ast::ptr< ast::Expr > inc = ast::UntypedExpr::createCall(
     296                        loc, update, { indexVar } );
     297
     298                ast::ptr< ast::Expr > dstIndex = ast::UntypedExpr::createCall(
     299                        loc, "?[?]", { dstParam, indexVar } );
     300
     301                // srcParam must keep track of the array indices to build the source parameter and/or
    300302                // array list initializer
    301303                srcParam.addArrayIndex( indexVar, array->dimension );
     
    303305                // for stmt's body, eventually containing call
    304306                ast::CompoundStmt * body = new ast::CompoundStmt{ loc };
    305                 ast::ptr< ast::Stmt > listInit = genCall( 
    306                         srcParam, dstIndex, loc, fname, std::back_inserter( body->kids ), array->base, addCast, 
     307                ast::ptr< ast::Stmt > listInit = genCall(
     308                        srcParam, dstIndex, loc, fname, std::back_inserter( body->kids ), array->base, addCast,
    307309                        forward );
    308                
     310
    309311                // block containing the stmt and index variable
    310312                ast::CompoundStmt * block = new ast::CompoundStmt{ loc };
     
    328330        template< typename OutIter >
    329331        ast::ptr< ast::Stmt > genCall(
    330                 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 
    331                 const CodeLocation & loc, const std::string & fname, OutIter && out, 
     332                InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     333                const CodeLocation & loc, const std::string & fname, OutIter && out,
    332334                const ast::Type * type, const ast::Type * addCast, LoopDirection forward
    333335        ) {
    334336                if ( auto at = dynamic_cast< const ast::ArrayType * >( type ) ) {
    335                         genArrayCall( 
    336                                 srcParam, dstParam, loc, fname, std::forward< OutIter >(out), at, addCast, 
     337                        genArrayCall(
     338                                srcParam, dstParam, loc, fname, std::forward< OutIter >(out), at, addCast,
    337339                                forward );
    338340                        return {};
    339341                } else {
    340                         return genScalarCall( 
     342                        return genScalarCall(
    341343                                srcParam, dstParam, loc, fname, std::forward< OutIter >( out ), type, addCast );
    342344                }
     
    377379        }
    378380
    379         static inline ast::ptr< ast::Stmt > genImplicitCall( 
    380                 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 
    381                 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, 
    382                 LoopDirection forward = LoopForward 
     381        static inline ast::ptr< ast::Stmt > genImplicitCall(
     382                InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     383                const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj,
     384                LoopDirection forward = LoopForward
    383385        ) {
    384386                // unnamed bit fields are not copied as they cannot be accessed
     
    392394
    393395                std::vector< ast::ptr< ast::Stmt > > stmts;
    394                 genCall( 
     396                genCall(
    395397                        srcParam, dstParam, loc, fname, back_inserter( stmts ), obj->type, addCast, forward );
    396398
     
    400402                        const ast::Stmt * callStmt = stmts.front();
    401403                        if ( addCast ) {
    402                                 // implicitly generated ctor/dtor calls should be wrapped so that later passes are 
     404                                // implicitly generated ctor/dtor calls should be wrapped so that later passes are
    403405                                // aware they were generated.
    404406                                callStmt = new ast::ImplicitCtorDtorStmt{ callStmt->location, callStmt };
     
    417419// compile-command: "make install" //
    418420// End: //
    419 
  • src/SymTab/Demangle.cc

    r015925a re5d9274  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Demangler.cc --
     7// Demangle.cc -- Convert a mangled name into a human readable name.
    88//
    99// Author           : Rob Schluntz
  • src/SymTab/Mangler.h

    r015925a re5d9274  
    111111}
    112112
    113 extern "C" {
    114         char * cforall_demangle(const char *, int);
    115 }
    116 
    117113// Local Variables: //
    118114// tab-width: 4 //
  • src/SymTab/Validate.cc

    r015925a re5d9274  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Apr 29  9:45:00 2022
    13 // Update Count     : 365
     12// Last Modified On : Tue May 17 14:36:00 2022
     13// Update Count     : 366
    1414//
    1515
     
    7474#include "ResolvExpr/ResolveTypeof.h"  // for resolveTypeof
    7575#include "SymTab/Autogen.h"            // for SizeType
     76#include "SymTab/ValidateType.h"       // for decayEnumsAndPointers, decayFo...
    7677#include "SynTree/LinkageSpec.h"       // for C
    7778#include "SynTree/Attribute.h"         // for noAttributes, Attribute
     
    134135        };
    135136
    136         /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.
    137         struct EnumAndPointerDecay_old {
    138                 void previsit( EnumDecl * aggregateDecl );
    139                 void previsit( FunctionType * func );
    140         };
    141 
    142         /// Associates forward declarations of aggregates with their definitions
    143         struct LinkReferenceToTypes_old final : public WithIndexer, public WithGuards, public WithVisitorRef<LinkReferenceToTypes_old>, public WithShortCircuiting {
    144                 LinkReferenceToTypes_old( const Indexer * indexer );
    145 
    146                 void postvisit( TypeInstType * typeInst );
    147 
    148                 void postvisit( EnumInstType * enumInst );
    149                 void postvisit( StructInstType * structInst );
    150                 void postvisit( UnionInstType * unionInst );
    151                 void postvisit( TraitInstType * traitInst );
    152                 void previsit( QualifiedType * qualType );
    153                 void postvisit( QualifiedType * qualType );
    154 
    155                 void postvisit( EnumDecl * enumDecl );
    156                 void postvisit( StructDecl * structDecl );
    157                 void postvisit( UnionDecl * unionDecl );
    158                 void postvisit( TraitDecl * traitDecl );
    159 
    160                 void previsit( StructDecl * structDecl );
    161                 void previsit( UnionDecl * unionDecl );
    162 
    163                 void renameGenericParams( std::list< TypeDecl * > & params );
    164 
    165           private:
    166                 const Indexer * local_indexer;
    167 
    168                 typedef std::map< std::string, std::list< EnumInstType * > > ForwardEnumsType;
    169                 typedef std::map< std::string, std::list< StructInstType * > > ForwardStructsType;
    170                 typedef std::map< std::string, std::list< UnionInstType * > > ForwardUnionsType;
    171                 ForwardEnumsType forwardEnums;
    172                 ForwardStructsType forwardStructs;
    173                 ForwardUnionsType forwardUnions;
    174                 /// true if currently in a generic type body, so that type parameter instances can be renamed appropriately
    175                 bool inGeneric = false;
    176         };
    177 
    178137        /// Does early resolution on the expressions that give enumeration constants their values
    179138        struct ResolveEnumInitializers final : public WithIndexer, public WithGuards, public WithVisitorRef<ResolveEnumInitializers>, public WithShortCircuiting {
     
    193152                void previsit( StructDecl * aggrDecl );
    194153                void previsit( UnionDecl * aggrDecl );
    195         };
    196 
    197         // These structs are the sub-sub-passes of ForallPointerDecay_old.
    198 
    199         struct TraitExpander_old final {
    200                 void previsit( FunctionType * );
    201                 void previsit( StructDecl * );
    202                 void previsit( UnionDecl * );
    203         };
    204 
    205         struct AssertionFixer_old final {
    206                 void previsit( FunctionType * );
    207                 void previsit( StructDecl * );
    208                 void previsit( UnionDecl * );
    209         };
    210 
    211         struct CheckOperatorTypes_old final {
    212                 void previsit( ObjectDecl * );
    213         };
    214 
    215         struct FixUniqueIds_old final {
    216                 void previsit( DeclarationWithType * );
    217154        };
    218155
     
    358295
    359296        void validate_A( std::list< Declaration * > & translationUnit ) {
    360                 PassVisitor<EnumAndPointerDecay_old> epc;
    361297                PassVisitor<HoistTypeDecls> hoistDecls;
    362298                {
     
    367303                        ReplaceTypedef::replaceTypedef( translationUnit );
    368304                        ReturnTypeFixer::fix( translationUnit ); // must happen before autogen
    369                         acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling
    370                 }
    371         }
    372 
    373         void linkReferenceToTypes( std::list< Declaration * > & translationUnit ) {
    374                 PassVisitor<LinkReferenceToTypes_old> lrt( nullptr );
    375                 acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
     305                        decayEnumsAndPointers( translationUnit ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling
     306                }
    376307        }
    377308
     
    412343                        });
    413344                }
    414         }
    415 
    416         static void decayForallPointers( std::list< Declaration * > & translationUnit ) {
    417                 PassVisitor<TraitExpander_old> te;
    418                 acceptAll( translationUnit, te );
    419                 PassVisitor<AssertionFixer_old> af;
    420                 acceptAll( translationUnit, af );
    421                 PassVisitor<CheckOperatorTypes_old> cot;
    422                 acceptAll( translationUnit, cot );
    423                 PassVisitor<FixUniqueIds_old> fui;
    424                 acceptAll( translationUnit, fui );
    425345        }
    426346
     
    501421        }
    502422
    503         void validateType( Type * type, const Indexer * indexer ) {
    504                 PassVisitor<EnumAndPointerDecay_old> epc;
    505                 PassVisitor<LinkReferenceToTypes_old> lrt( indexer );
    506                 PassVisitor<TraitExpander_old> te;
    507                 PassVisitor<AssertionFixer_old> af;
    508                 PassVisitor<CheckOperatorTypes_old> cot;
    509                 PassVisitor<FixUniqueIds_old> fui;
    510                 type->accept( epc );
    511                 type->accept( lrt );
    512                 type->accept( te );
    513                 type->accept( af );
    514                 type->accept( cot );
    515                 type->accept( fui );
    516         }
    517 
    518423        void HoistTypeDecls::handleType( Type * type ) {
    519424                // some type declarations are buried in expressions and not easy to hoist during parsing; hoist them here
     
    708613        }
    709614
    710         void EnumAndPointerDecay_old::previsit( EnumDecl * enumDecl ) {
    711                 // Set the type of each member of the enumeration to be EnumConstant
    712                 for ( std::list< Declaration * >::iterator i = enumDecl->members.begin(); i != enumDecl->members.end(); ++i ) {
    713                         ObjectDecl * obj = dynamic_cast< ObjectDecl * >( * i );
    714                         assert( obj );
    715                         obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->name ) );
    716                 } // for
    717         }
    718 
    719         namespace {
    720                 template< typename DWTList >
    721                 void fixFunctionList( DWTList & dwts, bool isVarArgs, FunctionType * func ) {
    722                         auto nvals = dwts.size();
    723                         bool containsVoid = false;
    724                         for ( auto & dwt : dwts ) {
    725                                 // fix each DWT and record whether a void was found
    726                                 containsVoid |= fixFunction( dwt );
    727                         }
    728 
    729                         // the only case in which "void" is valid is where it is the only one in the list
    730                         if ( containsVoid && ( nvals > 1 || isVarArgs ) ) {
    731                                 SemanticError( func, "invalid type void in function type " );
    732                         }
    733 
    734                         // one void is the only thing in the list; remove it.
    735                         if ( containsVoid ) {
    736                                 delete dwts.front();
    737                                 dwts.clear();
    738                         }
    739                 }
    740         }
    741 
    742         void EnumAndPointerDecay_old::previsit( FunctionType * func ) {
    743                 // Fix up parameters and return types
    744                 fixFunctionList( func->parameters, func->isVarArgs, func );
    745                 fixFunctionList( func->returnVals, false, func );
    746         }
    747 
    748         LinkReferenceToTypes_old::LinkReferenceToTypes_old( const Indexer * other_indexer ) : WithIndexer( false ) {
    749                 if ( other_indexer ) {
    750                         local_indexer = other_indexer;
    751                 } else {
    752                         local_indexer = &indexer;
    753                 } // if
    754         }
    755 
    756         void LinkReferenceToTypes_old::postvisit( EnumInstType * enumInst ) {
    757                 const EnumDecl * st = local_indexer->lookupEnum( enumInst->name );
    758                 // it's not a semantic error if the enum is not found, just an implicit forward declaration
    759                 if ( st ) {
    760                         enumInst->baseEnum = const_cast<EnumDecl *>(st); // Just linking in the node
    761                 } // if
    762                 if ( ! st || ! st->body ) {
    763                         // use of forward declaration
    764                         forwardEnums[ enumInst->name ].push_back( enumInst );
    765                 } // if
    766         }
    767         void LinkReferenceToTypes_old::postvisit( StructInstType * structInst ) {
    768                 const StructDecl * st = local_indexer->lookupStruct( structInst->name );
    769                 // it's not a semantic error if the struct is not found, just an implicit forward declaration
    770                 if ( st ) {
    771                         structInst->baseStruct = const_cast<StructDecl *>(st); // Just linking in the node
    772                 } // if
    773                 if ( ! st || ! st->body ) {
    774                         // use of forward declaration
    775                         forwardStructs[ structInst->name ].push_back( structInst );
    776                 } // if
    777         }
    778 
    779         void LinkReferenceToTypes_old::postvisit( UnionInstType * unionInst ) {
    780                 const UnionDecl * un = local_indexer->lookupUnion( unionInst->name );
    781                 // it's not a semantic error if the union is not found, just an implicit forward declaration
    782                 if ( un ) {
    783                         unionInst->baseUnion = const_cast<UnionDecl *>(un); // Just linking in the node
    784                 } // if
    785                 if ( ! un || ! un->body ) {
    786                         // use of forward declaration
    787                         forwardUnions[ unionInst->name ].push_back( unionInst );
    788                 } // if
    789         }
    790 
    791         void LinkReferenceToTypes_old::previsit( QualifiedType * ) {
    792                 visit_children = false;
    793         }
    794 
    795         void LinkReferenceToTypes_old::postvisit( QualifiedType * qualType ) {
    796                 // linking only makes sense for the 'oldest ancestor' of the qualified type
    797                 qualType->parent->accept( * visitor );
    798         }
    799 
    800         template< typename Decl >
    801         void normalizeAssertions( std::list< Decl * > & assertions ) {
    802                 // ensure no duplicate trait members after the clone
    803                 auto pred = [](Decl * d1, Decl * d2) {
    804                         // only care if they're equal
    805                         DeclarationWithType * dwt1 = dynamic_cast<DeclarationWithType *>( d1 );
    806                         DeclarationWithType * dwt2 = dynamic_cast<DeclarationWithType *>( d2 );
    807                         if ( dwt1 && dwt2 ) {
    808                                 if ( dwt1->name == dwt2->name && ResolvExpr::typesCompatible( dwt1->get_type(), dwt2->get_type(), SymTab::Indexer() ) ) {
    809                                         // std::cerr << "=========== equal:" << std::endl;
    810                                         // std::cerr << "d1: " << d1 << std::endl;
    811                                         // std::cerr << "d2: " << d2 << std::endl;
    812                                         return false;
    813                                 }
    814                         }
    815                         return d1 < d2;
    816                 };
    817                 std::set<Decl *, decltype(pred)> unique_members( assertions.begin(), assertions.end(), pred );
    818                 // if ( unique_members.size() != assertions.size() ) {
    819                 //      std::cerr << "============different" << std::endl;
    820                 //      std::cerr << unique_members.size() << " " << assertions.size() << std::endl;
    821                 // }
    822 
    823                 std::list< Decl * > order;
    824                 order.splice( order.end(), assertions );
    825                 std::copy_if( order.begin(), order.end(), back_inserter( assertions ), [&]( Decl * decl ) {
    826                         return unique_members.count( decl );
    827                 });
    828         }
    829 
    830615        // expand assertions from trait instance, performing the appropriate type variable substitutions
    831616        template< typename Iterator >
     
    838623                // substitute trait decl parameters for instance parameters
    839624                applySubstitution( inst->baseTrait->parameters.begin(), inst->baseTrait->parameters.end(), inst->parameters.begin(), asserts.begin(), asserts.end(), out );
    840         }
    841 
    842         void LinkReferenceToTypes_old::postvisit( TraitDecl * traitDecl ) {
    843                 if ( traitDecl->name == "sized" ) {
    844                         // "sized" is a special trait - flick the sized status on for the type variable
    845                         assertf( traitDecl->parameters.size() == 1, "Built-in trait 'sized' has incorrect number of parameters: %zd", traitDecl->parameters.size() );
    846                         TypeDecl * td = traitDecl->parameters.front();
    847                         td->set_sized( true );
    848                 }
    849 
    850                 // move assertions from type parameters into the body of the trait
    851                 for ( TypeDecl * td : traitDecl->parameters ) {
    852                         for ( DeclarationWithType * assert : td->assertions ) {
    853                                 if ( TraitInstType * inst = dynamic_cast< TraitInstType * >( assert->get_type() ) ) {
    854                                         expandAssertions( inst, back_inserter( traitDecl->members ) );
    855                                 } else {
    856                                         traitDecl->members.push_back( assert->clone() );
    857                                 }
    858                         }
    859                         deleteAll( td->assertions );
    860                         td->assertions.clear();
    861                 } // for
    862         }
    863 
    864         void LinkReferenceToTypes_old::postvisit( TraitInstType * traitInst ) {
    865                 // handle other traits
    866                 const TraitDecl * traitDecl = local_indexer->lookupTrait( traitInst->name );
    867                 if ( ! traitDecl ) {
    868                         SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );
    869                 } // if
    870                 if ( traitDecl->parameters.size() != traitInst->parameters.size() ) {
    871                         SemanticError( traitInst, "incorrect number of trait parameters: " );
    872                 } // if
    873                 traitInst->baseTrait = const_cast<TraitDecl *>(traitDecl); // Just linking in the node
    874 
    875                 // need to carry over the 'sized' status of each decl in the instance
    876                 for ( auto p : group_iterate( traitDecl->parameters, traitInst->parameters ) ) {
    877                         TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) );
    878                         if ( ! expr ) {
    879                                 SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );
    880                         }
    881                         if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) {
    882                                 TypeDecl * formalDecl = std::get<0>(p);
    883                                 TypeDecl * instDecl = inst->baseType;
    884                                 if ( formalDecl->get_sized() ) instDecl->set_sized( true );
    885                         }
    886                 }
    887                 // normalizeAssertions( traitInst->members );
    888         }
    889 
    890         void LinkReferenceToTypes_old::postvisit( EnumDecl * enumDecl ) {
    891                 // visit enum members first so that the types of self-referencing members are updated properly
    892                 // Replace the enum base; right now it works only for StructEnum
    893                 if ( enumDecl->base && dynamic_cast<TypeInstType*>(enumDecl->base) ) {
    894                         std::string baseName = static_cast<TypeInstType*>(enumDecl->base)->name;
    895                         const StructDecl * st = local_indexer->lookupStruct( baseName );
    896                         if ( st ) {
    897                                 enumDecl->base = new StructInstType(Type::Qualifiers(),const_cast<StructDecl *>(st)); // Just linking in the node
    898                         }
    899                 }
    900                 if ( enumDecl->body ) {
    901                         ForwardEnumsType::iterator fwds = forwardEnums.find( enumDecl->name );
    902                         if ( fwds != forwardEnums.end() ) {
    903                                 for ( std::list< EnumInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
    904                                         (* inst)->baseEnum = enumDecl;
    905                                 } // for
    906                                 forwardEnums.erase( fwds );
    907                         } // if
    908                 } // if
    909         }
    910 
    911         void LinkReferenceToTypes_old::renameGenericParams( std::list< TypeDecl * > & params ) {
    912                 // rename generic type parameters uniquely so that they do not conflict with user-defined function forall parameters, e.g.
    913                 //   forall(otype T)
    914                 //   struct Box {
    915                 //     T x;
    916                 //   };
    917                 //   forall(otype T)
    918                 //   void f(Box(T) b) {
    919                 //     ...
    920                 //   }
    921                 // The T in Box and the T in f are different, so internally the naming must reflect that.
    922                 GuardValue( inGeneric );
    923                 inGeneric = ! params.empty();
    924                 for ( TypeDecl * td : params ) {
    925                         td->name = "__" + td->name + "_generic_";
    926                 }
    927         }
    928 
    929         void LinkReferenceToTypes_old::previsit( StructDecl * structDecl ) {
    930                 renameGenericParams( structDecl->parameters );
    931         }
    932 
    933         void LinkReferenceToTypes_old::previsit( UnionDecl * unionDecl ) {
    934                 renameGenericParams( unionDecl->parameters );
    935         }
    936 
    937         void LinkReferenceToTypes_old::postvisit( StructDecl * structDecl ) {
    938                 // visit struct members first so that the types of self-referencing members are updated properly
    939                 // xxx - need to ensure that type parameters match up between forward declarations and definition (most importantly, number of type parameters and their defaults)
    940                 if ( structDecl->body ) {
    941                         ForwardStructsType::iterator fwds = forwardStructs.find( structDecl->name );
    942                         if ( fwds != forwardStructs.end() ) {
    943                                 for ( std::list< StructInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
    944                                         (* inst)->baseStruct = structDecl;
    945                                 } // for
    946                                 forwardStructs.erase( fwds );
    947                         } // if
    948                 } // if
    949         }
    950 
    951         void LinkReferenceToTypes_old::postvisit( UnionDecl * unionDecl ) {
    952                 if ( unionDecl->body ) {
    953                         ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl->name );
    954                         if ( fwds != forwardUnions.end() ) {
    955                                 for ( std::list< UnionInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
    956                                         (* inst)->baseUnion = unionDecl;
    957                                 } // for
    958                                 forwardUnions.erase( fwds );
    959                         } // if
    960                 } // if
    961         }
    962 
    963         void LinkReferenceToTypes_old::postvisit( TypeInstType * typeInst ) {
    964                 // ensure generic parameter instances are renamed like the base type
    965                 if ( inGeneric && typeInst->baseType ) typeInst->name = typeInst->baseType->name;
    966                 if ( const NamedTypeDecl * namedTypeDecl = local_indexer->lookupType( typeInst->name ) ) {
    967                         if ( const TypeDecl * typeDecl = dynamic_cast< const TypeDecl * >( namedTypeDecl ) ) {
    968                                 typeInst->set_isFtype( typeDecl->kind == TypeDecl::Ftype );
    969                         } // if
    970                 } // if
    971625        }
    972626
     
    997651                                                }
    998652                                        }
    999                                        
    1000653                                }
    1001654                        }
     
    1085738        void ForallPointerDecay_old::previsit( UnionDecl * aggrDecl ) {
    1086739                forallFixer( aggrDecl->parameters, aggrDecl );
    1087         }
    1088 
    1089         void TraitExpander_old::previsit( FunctionType * ftype ) {
    1090                 expandTraits( ftype->forall );
    1091         }
    1092 
    1093         void TraitExpander_old::previsit( StructDecl * aggrDecl ) {
    1094                 expandTraits( aggrDecl->parameters );
    1095         }
    1096 
    1097         void TraitExpander_old::previsit( UnionDecl * aggrDecl ) {
    1098                 expandTraits( aggrDecl->parameters );
    1099         }
    1100 
    1101         void AssertionFixer_old::previsit( FunctionType * ftype ) {
    1102                 fixAssertions( ftype->forall, ftype );
    1103         }
    1104 
    1105         void AssertionFixer_old::previsit( StructDecl * aggrDecl ) {
    1106                 fixAssertions( aggrDecl->parameters, aggrDecl );
    1107         }
    1108 
    1109         void AssertionFixer_old::previsit( UnionDecl * aggrDecl ) {
    1110                 fixAssertions( aggrDecl->parameters, aggrDecl );
    1111         }
    1112 
    1113         void CheckOperatorTypes_old::previsit( ObjectDecl * object ) {
    1114                 // ensure that operator names only apply to functions or function pointers
    1115                 if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) {
    1116                         SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." )  );
    1117                 }
    1118         }
    1119 
    1120         void FixUniqueIds_old::previsit( DeclarationWithType * decl ) {
    1121                 decl->fixUniqueId();
    1122740        }
    1123741
  • src/SymTab/Validate.h

    r015925a re5d9274  
    1010// Author           : Richard C. Bilson
    1111// Created On       : Sun May 17 21:53:34 2015
    12 // Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sat Jul 22 09:46:07 2017
    14 // Update Count     : 4
     12// Last Modified By : Andrew Beach
     13// Last Modified On : Tue May 17 14:35:00 2022
     14// Update Count     : 5
    1515//
    1616
     
    3333        /// Normalizes struct and function declarations
    3434        void validate( std::list< Declaration * > &translationUnit, bool doDebug = false );
    35         void validateType( Type *type, const Indexer *indexer );
    3635
    3736        // Sub-passes of validate.
     
    4241        void validate_E( std::list< Declaration * > &translationUnit );
    4342        void validate_F( std::list< Declaration * > &translationUnit );
    44         void linkReferenceToTypes( std::list< Declaration * > &translationUnit );
    45 
    46         const ast::Type * validateType(
    47                 const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab );
    4843} // namespace SymTab
    4944
  • src/SymTab/demangler.cc

    r015925a re5d9274  
    1 #include "Mangler.h"
     1#include "Demangle.h"
    22#include <iostream>
    33#include <fstream>
  • src/SymTab/module.mk

    r015925a re5d9274  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Andrew Beach
    13 ## Last Modified On : Thr Aug 10 16:08:00 2017
    14 ## Update Count     : 4
     13## Last Modified On : Tue May 17 14:46:00 2022
     14## Update Count     : 5
    1515###############################################################################
    1616
    1717SRC_SYMTAB = \
    18       SymTab/Autogen.cc \
    19       SymTab/Autogen.h \
    20       SymTab/FixFunction.cc \
    21       SymTab/FixFunction.h \
    22       SymTab/Indexer.cc \
    23       SymTab/Indexer.h \
    24       SymTab/Mangler.cc \
    25       SymTab/ManglerCommon.cc \
    26       SymTab/Mangler.h \
    27       SymTab/Validate.cc \
    28       SymTab/Validate.h
     18        SymTab/Autogen.cc \
     19        SymTab/Autogen.h \
     20        SymTab/FixFunction.cc \
     21        SymTab/FixFunction.h \
     22        SymTab/Indexer.cc \
     23        SymTab/Indexer.h \
     24        SymTab/Mangler.cc \
     25        SymTab/ManglerCommon.cc \
     26        SymTab/Mangler.h \
     27        SymTab/ValidateType.cc \
     28        SymTab/ValidateType.h
    2929
    30 SRC += $(SRC_SYMTAB)
    31 SRCDEMANGLE += $(SRC_SYMTAB) SymTab/Demangle.cc
     30SRC += $(SRC_SYMTAB) \
     31        SymTab/Validate.cc \
     32        SymTab/Validate.h
     33
     34SRCDEMANGLE += $(SRC_SYMTAB) \
     35        SymTab/Demangle.cc \
     36        SymTab/Demangle.h
  • src/SynTree/module.mk

    r015925a re5d9274  
    2424      SynTree/AttrType.cc \
    2525      SynTree/BaseSyntaxNode.h \
     26      SynTree/BaseSyntaxNode.cc \
    2627      SynTree/BasicType.cc \
    2728      SynTree/CommaExpr.cc \
  • src/Tuples/TupleExpansion.cc

    r015925a re5d9274  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 23:45:51 2019
    13 // Update Count     : 24
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue May 17 15:02:00 2022
     13// Update Count     : 25
    1414//
    1515
     
    367367                return nullptr;
    368368        }
    369 
    370         namespace {
    371                 /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure
    372                 struct ImpurityDetector : public WithShortCircuiting {
    373                         ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {}
    374 
    375                         void previsit( const ApplicationExpr * appExpr ) {
    376                                 visit_children = false;
    377                                 if ( const DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) {
    378                                         if ( function->linkage == LinkageSpec::Intrinsic ) {
    379                                                 if ( function->name == "*?" || function->name == "?[?]" ) {
    380                                                         // intrinsic dereference, subscript are pure, but need to recursively look for impurity
    381                                                         visit_children = true;
    382                                                         return;
    383                                                 }
    384                                         }
    385                                 }
    386                                 maybeImpure = true;
    387                         }
    388                         void previsit( const UntypedExpr * ) { maybeImpure = true; visit_children = false; }
    389                         void previsit( const UniqueExpr * ) {
    390                                 if ( ignoreUnique ) {
    391                                         // bottom out at unique expression.
    392                                         // The existence of a unique expression doesn't change the purity of an expression.
    393                                         // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.
    394                                         visit_children = false;
    395                                         return;
    396                                 }
    397                         }
    398 
    399                         bool maybeImpure = false;
    400                         bool ignoreUnique;
    401                 };
    402         } // namespace
    403 
    404         bool maybeImpure( const Expression * expr ) {
    405                 PassVisitor<ImpurityDetector> detector( false );
    406                 expr->accept( detector );
    407                 return detector.pass.maybeImpure;
    408         }
    409 
    410         bool maybeImpureIgnoreUnique( const Expression * expr ) {
    411                 PassVisitor<ImpurityDetector> detector( true );
    412                 expr->accept( detector );
    413                 return detector.pass.maybeImpure;
    414         }
    415369} // namespace Tuples
    416370
  • src/Tuples/Tuples.cc

    r015925a re5d9274  
    1010// Created On       : Mon Jun 17 14:41:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Jun 18  9:31:00 2019
    13 // Update Count     : 1
     12// Last Modified On : Mon May 16 16:15:00 2022
     13// Update Count     : 2
    1414//
    1515
     
    1818#include "AST/Pass.hpp"
    1919#include "AST/LinkageSpec.hpp"
     20#include "Common/PassVisitor.h"
    2021#include "InitTweak/InitTweak.h"
    2122
     
    2324
    2425namespace {
     26        /// Checks if impurity (read: side-effects) may exist in a piece of code.
     27        /// Currently gives a very crude approximation, wherein any function
     28        /// call expression means the code may be impure.
     29        struct ImpurityDetector_old : public WithShortCircuiting {
     30                bool const ignoreUnique;
     31                bool maybeImpure;
     32
     33                ImpurityDetector_old( bool ignoreUnique ) :
     34                        ignoreUnique( ignoreUnique ), maybeImpure( false )
     35                {}
     36
     37                void previsit( const ApplicationExpr * appExpr ) {
     38                        visit_children = false;
     39                        if ( const DeclarationWithType * function =
     40                                        InitTweak::getFunction( appExpr ) ) {
     41                                if ( function->linkage == LinkageSpec::Intrinsic ) {
     42                                        if ( function->name == "*?" || function->name == "?[?]" ) {
     43                                                // intrinsic dereference, subscript are pure,
     44                                                // but need to recursively look for impurity
     45                                                visit_children = true;
     46                                                return;
     47                                        }
     48                                }
     49                        }
     50                        maybeImpure = true;
     51                }
     52
     53                void previsit( const UntypedExpr * ) {
     54                        maybeImpure = true;
     55                        visit_children = false;
     56                }
     57
     58                void previsit( const UniqueExpr * ) {
     59                        if ( ignoreUnique ) {
     60                                // bottom out at unique expression.
     61                                // The existence of a unique expression doesn't change the purity of an expression.
     62                                // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.
     63                                visit_children = false;
     64                                return;
     65                        }
     66                }
     67        };
     68
     69        bool detectImpurity( const Expression * expr, bool ignoreUnique ) {
     70                PassVisitor<ImpurityDetector_old> detector( ignoreUnique );
     71                expr->accept( detector );
     72                return detector.pass.maybeImpure;
     73        }
     74
    2575        /// Determines if impurity (read: side-effects) may exist in a piece of code. Currently gives
    2676        /// a very crude approximation, wherein any function call expression means the code may be
    2777        /// impure.
    2878    struct ImpurityDetector : public ast::WithShortCircuiting {
    29                 bool maybeImpure = false;
     79                bool result = false;
    3080
    3181                void previsit( ast::ApplicationExpr const * appExpr ) {
     
    3686                                }
    3787                        }
    38                         maybeImpure = true; visit_children = false;
     88                        result = true; visit_children = false;
    3989                }
    4090                void previsit( ast::UntypedExpr const * ) {
    41                         maybeImpure = true; visit_children = false;
     91                        result = true; visit_children = false;
    4292                }
    4393        };
     94
    4495        struct ImpurityDetectorIgnoreUnique : public ImpurityDetector {
    4596                using ImpurityDetector::previsit;
     
    4899                }
    49100        };
    50 
    51         template<typename Detector>
    52         bool detectImpurity( const ast::Expr * expr ) {
    53                 ast::Pass<Detector> detector;
    54                 expr->accept( detector );
    55                 return detector.core.maybeImpure;
    56         }
    57101} // namespace
    58102
    59103bool maybeImpure( const ast::Expr * expr ) {
    60         return detectImpurity<ImpurityDetector>( expr );
     104        return ast::Pass<ImpurityDetector>::read( expr );
    61105}
    62106
    63107bool maybeImpureIgnoreUnique( const ast::Expr * expr ) {
    64         return detectImpurity<ImpurityDetectorIgnoreUnique>( expr );
     108        return ast::Pass<ImpurityDetectorIgnoreUnique>::read( expr );
     109}
     110
     111bool maybeImpure( const Expression * expr ) {
     112        return detectImpurity( expr, false );
     113}
     114
     115bool maybeImpureIgnoreUnique( const Expression * expr ) {
     116        return detectImpurity( expr, true );
    65117}
    66118
  • src/Tuples/module.mk

    r015925a re5d9274  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Henry Xue
    13 ## Last Modified On : Mon Aug 23 15:36:09 2021
    14 ## Update Count     : 2
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Mon May 17 15:00:00 2022
     14## Update Count     : 3
    1515###############################################################################
    1616
     
    2424        Tuples/Tuples.h
    2525
     26SRC += $(SRC_TUPLES)
    2627
    27 SRC += $(SRC_TUPLES)
    2828SRCDEMANGLE += $(SRC_TUPLES)
  • src/Validate/Autogen.cpp

    r015925a re5d9274  
    402402        auto retval = srcParam();
    403403        retval->name = "_ret";
     404        // xxx - Adding this unused attribute can slience unused variable warning
     405        // However, some code might not be compiled as expected
     406        // Temporarily disabled
     407        // retval->attributes.push_back(new ast::Attribute("unused"));
    404408        return genProto( "?=?", { dstParam(), srcParam() }, { retval } );
    405409}
  • src/Validate/module.mk

    r015925a re5d9274  
    1010## Author           : Rob Schluntz
    1111## Created On       : Fri Jul 27 10:10:10 2018
    12 ## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Fri Jul 27 10:10:26 2018
    14 ## Update Count     : 2
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Tue May 17 14:59:00 2022
     14## Update Count     : 3
    1515###############################################################################
    1616
    1717SRC_VALIDATE = \
     18        Validate/FindSpecialDecls.cc \
     19        Validate/FindSpecialDecls.h
     20
     21SRC += $(SRC_VALIDATE) \
    1822        Validate/Autogen.cpp \
    1923        Validate/Autogen.hpp \
     
    2226        Validate/EliminateTypedef.cpp \
    2327        Validate/EliminateTypedef.hpp \
     28        Validate/FindSpecialDeclsNew.cpp \
    2429        Validate/FixQualifiedTypes.cpp \
    2530        Validate/FixQualifiedTypes.hpp \
     
    3843        Validate/NoIdSymbolTable.hpp \
    3944        Validate/ReturnCheck.cpp \
    40         Validate/ReturnCheck.hpp \
    41         Validate/FindSpecialDeclsNew.cpp \
    42         Validate/FindSpecialDecls.cc \
    43         Validate/FindSpecialDecls.h
     45        Validate/ReturnCheck.hpp
    4446
    45 SRC += $(SRC_VALIDATE)
    4647SRCDEMANGLE += $(SRC_VALIDATE)
  • src/Virtual/module.mk

    r015925a re5d9274  
    1111## Created On       : Tus Jul 25 10:18:00 2017
    1212## Last Modified By : Andrew Beach
    13 ## Last Modified On : Tus Jul 25 10:18:00 2017
    14 ## Update Count     : 0
     13## Last Modified On : Tus May 17 14:59:00 2022
     14## Update Count     : 1
    1515###############################################################################
    1616
    17 SRC += Virtual/ExpandCasts.cc Virtual/ExpandCasts.h \
    18         Virtual/Tables.cc Virtual/Tables.h
    19 
    20 SRCDEMANGLE += Virtual/Tables.cc
     17SRC += \
     18        Virtual/ExpandCasts.cc \
     19        Virtual/ExpandCasts.h \
     20        Virtual/Tables.cc \
     21        Virtual/Tables.h
  • src/main.cc

    r015925a re5d9274  
    7070#include "ResolvExpr/Resolver.h"            // for resolve
    7171#include "SymTab/Validate.h"                // for validate
     72#include "SymTab/ValidateType.h"            // for linkReferenceToTypes
    7273#include "SynTree/LinkageSpec.h"            // for Spec, Cforall, Intrinsic
    7374#include "SynTree/Declaration.h"            // for Declaration
Note: See TracChangeset for help on using the changeset viewer.