Changeset 4934ea3


Ignore:
Timestamp:
Jul 30, 2018, 4:43:47 PM (3 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
2ff9f4a
Parents:
f072892
git-author:
Rob Schluntz <rschlunt@…> (07/26/18 15:04:52)
git-committer:
Rob Schluntz <rschlunt@…> (07/30/18 16:43:47)
Message:

Resolve array dimensions early to correctly evaluate whether a type is VLA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rf072892 r4934ea3  
    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
     
    247248        };
    248249
    249         struct ArrayLength {
     250        struct ArrayLength : public WithIndexer {
    250251                /// for array types without an explicit length, compute the length and store it so that it
    251252                /// is known to the rest of the phases. For example,
     
    258259
    259260                void previsit( ObjectDecl * objDecl );
     261                void previsit( ArrayType * arrayType );
    260262        };
    261263
     
    12391241        }
    12401242
     1243        void ArrayLength::previsit( ArrayType * type ) {
     1244                if ( type->dimension ) {
     1245                        // need to resolve array dimensions early so that constructor code can correctly determine
     1246                        // if a type is a VLA (and hence whether its elements need to be constructed)
     1247                        ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );
     1248
     1249                        // must re-evaluate whether a type is a VLA, now that more information is available
     1250                        // (e.g. the dimension may have been an enumerator, which was unknown prior to this step)
     1251                        type->isVarLen = ! InitTweak::isConstExpr( type->dimension );
     1252                }
     1253        }
     1254
    12411255        struct LabelFinder {
    12421256                std::set< Label > & labels;
Note: See TracChangeset for help on using the changeset viewer.