Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rc8e4d2f8 r0d70e0d  
    7676#include "SynTree/Visitor.h"           // for Visitor
    7777#include "Validate/HandleAttributes.h" // for handleAttributes
    78 #include "Validate/FindSpecialDecls.h" // for FindSpecialDecls
    7978
    8079class CompoundStmt;
     
    289288        };
    290289
     290        FunctionDecl * dereferenceOperator = nullptr;
     291        struct FindSpecialDeclarations final {
     292                void previsit( FunctionDecl * funcDecl );
     293        };
     294
    291295        void validate( std::list< Declaration * > &translationUnit, __attribute__((unused)) bool doDebug ) {
    292296                PassVisitor<EnumAndPointerDecay> epc;
     
    295299                PassVisitor<CompoundLiteral> compoundliteral;
    296300                PassVisitor<ValidateGenericParameters> genericParams;
     301                PassVisitor<FindSpecialDeclarations> finder;
    297302                PassVisitor<LabelAddressFixer> labelAddrFixer;
    298303                PassVisitor<HoistTypeDecls> hoistDecls;
     
    373378                        });
    374379                        Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    375                                 Validate::findSpecialDecls( translationUnit );
     380                                acceptAll( translationUnit, finder ); // xxx - remove this pass soon
    376381                        });
    377382                        Stats::Time::TimeBlock("Fix Label Address", [&]() {
     
    938943                if ( eliminator.pass.typedefNames.count( "size_t" ) ) {
    939944                        // grab and remember declaration of size_t
    940                         Validate::SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
     945                        SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
    941946                } else {
    942947                        // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong
    943948                        // eventually should have a warning for this case.
    944                         Validate::SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     949                        SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    945950                }
    946951        }
     
    13301335                        // need to resolve array dimensions early so that constructor code can correctly determine
    13311336                        // if a type is a VLA (and hence whether its elements need to be constructed)
    1332                         ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer );
     1337                        ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );
    13331338
    13341339                        // must re-evaluate whether a type is a VLA, now that more information is available
     
    13681373        }
    13691374
    1370         const ast::Type * validateType( const ast::Type * type, const ast::SymbolTable & symtab ) {
    1371                 #warning unimplemented
    1372                 (void)type; (void)symtab;
    1373                 assert(false);
    1374                 return nullptr;
     1375        void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) {
     1376                if ( ! dereferenceOperator ) {
     1377                        if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) {
     1378                                FunctionType * ftype = funcDecl->get_functionType();
     1379                                if ( ftype->get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) {
     1380                                        dereferenceOperator = funcDecl;
     1381                                }
     1382                        }
     1383                }
    13751384        }
    13761385} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.