Ignore:
Timestamp:
Aug 9, 2018, 6:35:02 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
ea5b7d6
Parents:
fb975a50 (diff), 0c827019 (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' into jenkins-sandbox

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rfb975a50 r455a7d5  
    6161#include "Parser/LinkageSpec.h"        // for C
    6262#include "ResolvExpr/typeops.h"        // for typesCompatible
     63#include "ResolvExpr/Resolver.h"       // for findSingleExpression
    6364#include "SymTab/Autogen.h"            // for SizeType
    6465#include "SynTree/Attribute.h"         // for noAttributes, Attribute
     
    7273#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
    7374#include "SynTree/Visitor.h"           // for Visitor
     75#include "Validate/HandleAttributes.h" // for handleAttributes
    7476
    7577class CompoundStmt;
     
    247249        };
    248250
    249         struct ArrayLength {
     251        struct ArrayLength : public WithIndexer {
    250252                /// for array types without an explicit length, compute the length and store it so that it
    251253                /// is known to the rest of the phases. For example,
     
    258260
    259261                void previsit( ObjectDecl * objDecl );
     262                void previsit( ArrayType * arrayType );
    260263        };
    261264
     
    312315                acceptAll( translationUnit, finder ); // xxx - remove this pass soon
    313316                mutateAll( translationUnit, labelAddrFixer );
     317                Validate::handleAttributes( translationUnit );
    314318        }
    315319
     
    734738                                forwardEnums.erase( fwds );
    735739                        } // 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                        }
    736749                } // if
    737750        }
     
    12321245        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    12331246                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    1234                         if ( at->get_dimension() ) return;
     1247                        if ( at->dimension ) return;
    12351248                        if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) {
    1236                                 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) );
    1237                         }
     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 );
    12381263                }
    12391264        }
Note: See TracChangeset for help on using the changeset viewer.