Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r98538288 rb4f8808  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 23:43:34 2019
    13 // Update Count     : 363
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  7 6:42:00 2019
     13// Update Count     : 360
    1414//
    1515
     
    6969#include "InitTweak/GenInit.h"         // for fixReturnStatements
    7070#include "InitTweak/InitTweak.h"       // for isCtorDtorAssign
     71#include "Parser/LinkageSpec.h"        // for C
    7172#include "ResolvExpr/typeops.h"        // for typesCompatible
    7273#include "ResolvExpr/Resolver.h"       // for findSingleExpression
    7374#include "ResolvExpr/ResolveTypeof.h"  // for resolveTypeof
    7475#include "SymTab/Autogen.h"            // for SizeType
    75 #include "SynTree/LinkageSpec.h"       // for C
    7676#include "SynTree/Attribute.h"         // for noAttributes, Attribute
    7777#include "SynTree/Constant.h"          // for Constant
     
    311311                        Stats::Heap::newPass("validate-A");
    312312                        Stats::Time::BlockGuard guard("validate-A");
    313                         VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    314313                        acceptAll( translationUnit, hoistDecls );
    315314                        ReplaceTypedef::replaceTypedef( translationUnit );
     
    337336                        Stats::Time::BlockGuard guard("validate-C");
    338337                        acceptAll( translationUnit, genericParams );  // check as early as possible - can't happen before LinkReferenceToTypes_old
     338                        VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    339339                        ReturnChecker::checkFunctionReturns( translationUnit );
    340340                        InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen
     
    375375                        Stats::Heap::newPass("validate-F");
    376376                        Stats::Time::BlockGuard guard("validate-F");
    377                         Stats::Time::TimeCall("Fix Object Type",
    378                                 FixObjectType::fix, translationUnit);
    379                         Stats::Time::TimeCall("Array Length",
    380                                 ArrayLength::computeLength, translationUnit);
    381                         Stats::Time::TimeCall("Find Special Declarations",
    382                                 Validate::findSpecialDecls, translationUnit);
    383                         Stats::Time::TimeCall("Fix Label Address",
    384                                 mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer);
    385                         Stats::Time::TimeCall("Handle Attributes",
    386                                 Validate::handleAttributes, translationUnit);
     377                        Stats::Time::TimeBlock("Fix Object Type", [&]() {
     378                                FixObjectType::fix( translationUnit );
     379                        });
     380                        Stats::Time::TimeBlock("Array Length", [&]() {
     381                                ArrayLength::computeLength( translationUnit );
     382                        });
     383                        Stats::Time::TimeBlock("Find Special Declarations", [&]() {
     384                                Validate::findSpecialDecls( translationUnit );
     385                        });
     386                        Stats::Time::TimeBlock("Fix Label Address", [&]() {
     387                                mutateAll( translationUnit, labelAddrFixer );
     388                        });
     389                        Stats::Time::TimeBlock("Handle Attributes", [&]() {
     390                                Validate::handleAttributes( translationUnit );
     391                        });
    387392                }
    388393        }
     
    10441049                Type * designatorType = tyDecl->base->stripDeclarator();
    10451050                if ( StructInstType * aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) {
    1046                         declsToAddBefore.push_back( new StructDecl( aggDecl->name, AggregateDecl::Struct, noAttributes, tyDecl->linkage ) );
     1051                        declsToAddBefore.push_back( new StructDecl( aggDecl->name, DeclarationNode::Struct, noAttributes, tyDecl->linkage ) );
    10471052                } else if ( UnionInstType * aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    10481053                        declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) );
     
    11821187                if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc.
    11831188                        if ( params.size() == 0 ) {
    1184                                 SemanticError( funcDecl->location, "Constructors, destructors, and assignment functions require at least one parameter." );
     1189                                SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );
    11851190                        }
    11861191                        ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() );
    11871192                        if ( ! refType ) {
    1188                                 SemanticError( funcDecl->location, "First parameter of a constructor, destructor, or assignment function must be a reference." );
     1193                                SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );
    11891194                        }
    11901195                        if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    1191                                 if(!returnVals.front()->get_type()->isVoid()) {
    1192                                         SemanticError( funcDecl->location, "Constructors and destructors cannot have explicit return values." );
    1193                                 }
     1196                                SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );
    11941197                        }
    11951198                }
Note: See TracChangeset for help on using the changeset viewer.