Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rac3362c r8a3ecb9  
    6161#include "Parser/LinkageSpec.h"        // for C
    6262#include "ResolvExpr/typeops.h"        // for typesCompatible
    63 #include "ResolvExpr/Resolver.h"       // for findSingleExpression
    6463#include "SymTab/Autogen.h"            // for SizeType
    6564#include "SynTree/Attribute.h"         // for noAttributes, Attribute
     
    7372#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
    7473#include "SynTree/Visitor.h"           // for Visitor
    75 #include "Validate/HandleAttributes.h" // for handleAttributes
    7674
    7775class CompoundStmt;
     
    8785                void previsit( AlignofExpr * );
    8886                void previsit( UntypedOffsetofExpr * );
    89                 void previsit( CompoundLiteralExpr * );
    9087                void handleType( Type * );
    9188        };
     
    249246        };
    250247
    251         struct ArrayLength : public WithIndexer {
     248        struct ArrayLength {
    252249                /// for array types without an explicit length, compute the length and store it so that it
    253250                /// is known to the rest of the phases. For example,
     
    260257
    261258                void previsit( ObjectDecl * objDecl );
    262                 void previsit( ArrayType * arrayType );
    263259        };
    264260
     
    315311                acceptAll( translationUnit, finder ); // xxx - remove this pass soon
    316312                mutateAll( translationUnit, labelAddrFixer );
    317                 Validate::handleAttributes( translationUnit );
    318313        }
    319314
     
    353348        void HoistTypeDecls::previsit( UntypedOffsetofExpr * expr ) {
    354349                handleType( expr->type );
    355         }
    356 
    357         void HoistTypeDecls::previsit( CompoundLiteralExpr * expr ) {
    358                 handleType( expr->result );
    359350        }
    360351
     
    738729                                forwardEnums.erase( fwds );
    739730                        } // if
    740 
    741                         for ( Declaration * member : enumDecl->members ) {
    742                                 ObjectDecl * field = strict_dynamic_cast<ObjectDecl *>( member );
    743                                 if ( field->init ) {
    744                                         // need to resolve enumerator initializers early so that other passes that determine if an expression is constexpr have the appropriate information.
    745                                         SingleInit * init = strict_dynamic_cast<SingleInit *>( field->init );
    746                                         ResolvExpr::findSingleExpression( init->value, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), indexer );
    747                                 }
    748                         }
    749731                } // if
    750732        }
     
    12451227        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    12461228                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    1247                         if ( at->dimension ) return;
     1229                        if ( at->get_dimension() ) return;
    12481230                        if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) {
    1249                                 at->dimension = new ConstantExpr( Constant::from_ulong( init->initializers.size() ) );
    1250                         }
    1251                 }
    1252         }
    1253 
    1254         void ArrayLength::previsit( ArrayType * type ) {
    1255                 if ( type->dimension ) {
    1256                         // need to resolve array dimensions early so that constructor code can correctly determine
    1257                         // if a type is a VLA (and hence whether its elements need to be constructed)
    1258                         ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );
    1259 
    1260                         // must re-evaluate whether a type is a VLA, now that more information is available
    1261                         // (e.g. the dimension may have been an enumerator, which was unknown prior to this step)
    1262                         type->isVarLen = ! InitTweak::isConstExpr( type->dimension );
     1231                                at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) );
     1232                        }
    12631233                }
    12641234        }
Note: See TracChangeset for help on using the changeset viewer.