Changes in / [9aa9126:7a7ab42]


Ignore:
Files:
7 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r9aa9126 r7a7ab42  
    2828
    2929# src executables, for lib and bin
    30 src/driver/as
     30src/driver/cc1
    3131src/driver/cfa
    3232src/driver/cfa-cpp
    33 src/driver/cc1
    3433
    3534src/prelude/bootloader.c
  • driver/Makefile.am

    r9aa9126 r7a7ab42  
    1111## Created On       : Sun May 31 08:49:31 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Thu Aug  2 12:18:25 2018
    14 ## Update Count     : 14
     13## Last Modified On : Mon Apr 30 17:44:17 2018
     14## Update Count     : 11
    1515###############################################################################
    1616
     
    3535# put into lib for now
    3636cc1libdir = ${CFA_LIBDIR}
    37 cc1lib_PROGRAMS = as cc1
    38 as_SOURCES = as.cc
     37cc1lib_PROGRAMS = cc1
    3938cc1_SOURCES = cc1.cc
    4039
     40# cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT)
     41#       cp $(<) $(@)
     42
    4143MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS}
  • driver/Makefile.in

    r9aa9126 r7a7ab42  
    9393host_triplet = @host@
    9494noinst_PROGRAMS = cfa$(EXEEXT)
    95 cc1lib_PROGRAMS = as$(EXEEXT) cc1$(EXEEXT)
     95cc1lib_PROGRAMS = cc1$(EXEEXT)
    9696subdir = driver
    9797ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
     
    107107am__installdirs = "$(DESTDIR)$(cc1libdir)"
    108108PROGRAMS = $(cc1lib_PROGRAMS) $(noinst_PROGRAMS)
    109 am_as_OBJECTS = as.$(OBJEXT)
    110 as_OBJECTS = $(am_as_OBJECTS)
    111 as_LDADD = $(LDADD)
    112109am_cc1_OBJECTS = cc1.$(OBJEXT)
    113110cc1_OBJECTS = $(am_cc1_OBJECTS)
     
    145142am__v_CXXLD_0 = @echo "  CXXLD   " $@;
    146143am__v_CXXLD_1 =
    147 SOURCES = $(as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES)
    148 DIST_SOURCES = $(as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES)
     144SOURCES = $(cc1_SOURCES) $(cfa_SOURCES)
     145DIST_SOURCES = $(cc1_SOURCES) $(cfa_SOURCES)
    149146am__can_run_installinfo = \
    150147  case $$AM_UPDATE_INFO_DIR in \
     
    305302# put into lib for now
    306303cc1libdir = ${CFA_LIBDIR}
    307 as_SOURCES = as.cc
    308304cc1_SOURCES = cc1.cc
     305
     306# cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT)
     307#       cp $(<) $(@)
    309308MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS}
    310309all: all-am
     
    387386        -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
    388387
    389 as$(EXEEXT): $(as_OBJECTS) $(as_DEPENDENCIES) $(EXTRA_as_DEPENDENCIES)
    390         @rm -f as$(EXEEXT)
    391         $(AM_V_CXXLD)$(CXXLINK) $(as_OBJECTS) $(as_LDADD) $(LIBS)
    392 
    393388cc1$(EXEEXT): $(cc1_OBJECTS) $(cc1_DEPENDENCIES) $(EXTRA_cc1_DEPENDENCIES)
    394389        @rm -f cc1$(EXEEXT)
     
    405400        -rm -f *.tab.c
    406401
    407 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/as.Po@am__quote@
    408402@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc1.Po@am__quote@
    409403@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfa.Po@am__quote@
  • driver/cfa.cc

    r9aa9126 r7a7ab42  
    402402                args[nargs] = "--undefined=__cfaabi_appready_startup";
    403403                nargs += 1;
    404                 args[nargs] = "-Xlinker";
    405                 nargs += 1;
    406                 args[nargs] = "--undefined=__cfaabi_dbg_record";
    407                 nargs += 1;
    408404
    409405                // include the cfa library in case it's needed
  • libcfa/prelude/builtins.c

    r9aa9126 r7a7ab42  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  5 21:40:38 2018
    13 // Update Count     : 20
     12// Last Modified On : Thu Feb  8 12:47:59 2018
     13// Update Count     : 19
    1414//
    1515
     
    2222
    2323void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    24 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     24void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    2525
    2626// increment/decrement unification
  • libcfa/src/bits/locks.hfa

    r9aa9126 r7a7ab42  
    6464                extern void disable_interrupts();
    6565                extern void enable_interrupts_noPoll();
    66 
    67                 #ifdef __CFA_DEBUG__
    68                         void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
    69                 #else
    70                         #define __cfaabi_dbg_record(x, y)
    71                 #endif
    7266        }
    7367
     
    7771                this.lock = 0;
    7872        }
     73
     74
     75        #ifdef __CFA_DEBUG__
     76                void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
     77        #else
     78                #define __cfaabi_dbg_record(x, y)
     79        #endif
    7980
    8081        // Lock the spinlock, return false if already acquired
  • libcfa/src/concurrency/kernel.cfa

    r9aa9126 r7a7ab42  
    833833// Debug
    834834__cfaabi_dbg_debug_do(
    835         extern "C" {
    836                 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
    837                         this.prev_name = prev_name;
    838                         this.prev_thrd = kernelTLS.this_thread;
    839                 }
     835        void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
     836                this.prev_name = prev_name;
     837                this.prev_thrd = kernelTLS.this_thread;
    840838        }
    841839)
  • libcfa/src/startup.cfa

    r9aa9126 r7a7ab42  
    4040
    4141struct __spinlock_t;
    42 extern "C" {
    43         void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {}
    44 }
     42void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {}
    4543
    4644// Local Variables: //
  • src/CodeGen/GenType.cc

    r9aa9126 r7a7ab42  
    2727namespace CodeGen {
    2828        struct GenType : public WithVisitorRef<GenType>, public WithShortCircuiting {
    29                 std::string typeString;
    30                 GenType( const std::string &typeString, bool pretty, bool genC, bool lineMarks );
     29                GenType( const std::string &typeString, bool pretty = false, bool genC = false, bool lineMarks = false );
     30                std::string get_typeString() const { return typeString; }
     31                void set_typeString( const std::string &newValue ) { typeString = newValue; }
    3132
    3233                void previsit( BaseSyntaxNode * );
     
    5758                void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
    5859
    59                 bool pretty = false;    // pretty print
    60                 bool genC = false;      // generating C code?
    61                 bool lineMarks = false; // lineMarks on for CodeGenerator?
     60                std::string typeString;
     61                bool pretty = false; // pretty print
     62                bool genC = false;   // generating C code?
     63                bool lineMarks = false;
    6264        };
    6365
     
    7274
    7375                type->accept( gt );
    74                 return os.str() + gt.pass.typeString;
     76                return os.str() + gt.pass.get_typeString();
    7577        }
    7678
  • src/Common/SemanticError.h

    r9aa9126 r7a7ab42  
    5858        {"aggregate-forward-decl" , "forward declaration of nested aggregate: %s"  , Severity::Warn},
    5959        {"superfluous-decl"       , "declaration does not allocate storage: %s"    , Severity::Warn},
    60         {"gcc-attributes"         , "invalid attribute: %s"                        , Severity::Warn},
    6160};
    6261
     
    6766        AggrForwardDecl,
    6867        SuperfluousDecl,
    69         GccAttributes,
    7068        NUMBER_OF_WARNINGS, // This MUST be the last warning
    7169};
  • src/Common/module.mk

    r9aa9126 r7a7ab42  
    1919       Common/DebugMalloc.cc \
    2020       Common/Assert.cc \
    21        Common/Heap.cc \
    22        Common/Eval.cc
     21       Common/Heap.cc
  • src/Common/utility.h

    r9aa9126 r7a7ab42  
    3131#include "Common/Indenter.h"
    3232
    33 class Expression;
    34 
    3533template< typename T >
    3634static inline T * maybeClone( const T *orig ) {
     
    458456} // ilog2
    459457
    460 // -----------------------------------------------------------------------------
    461 /// evaluates expr as a long long int. If second is false, expr could not be evaluated
    462 std::pair<long long int, bool> eval(Expression * expr);
    463458
    464459// Local Variables: //
  • src/InitTweak/FixGlobalInit.cc

    r9aa9126 r7a7ab42  
    3737        class GlobalFixer : public WithShortCircuiting {
    3838          public:
    39                 GlobalFixer( bool inLibrary );
     39                GlobalFixer( const std::string & name, bool inLibrary );
    4040
    4141                void previsit( ObjectDecl *objDecl );
     
    5252        };
    5353
    54         void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary ) {
    55                 PassVisitor<GlobalFixer> visitor( inLibrary );
     54        void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ) {
     55                PassVisitor<GlobalFixer> visitor( name, inLibrary );
    5656                acceptAll( translationUnit, visitor );
    5757                GlobalFixer & fixer = visitor.pass;
     
    7070        }
    7171
    72         GlobalFixer::GlobalFixer( bool inLibrary ) : tempNamer( "_global_init" ) {
     72  std::string globalFunctionName( const std::string & name ) {
     73        // get basename
     74        std::string ret = name.substr( 0, name.find( '.' ) );
     75        // replace invalid characters with _
     76                static std::string invalid = "/-@";
     77        replace_if( ret.begin(), ret.end(), []( char c ) { return invalid.find(c) != std::string::npos; }, '_' );
     78        return ret;
     79  }
     80
     81        GlobalFixer::GlobalFixer( const std::string & name, bool inLibrary ) : tempNamer( "_global_init" ) {
     82                std::string fixedName = globalFunctionName( name );
    7383                std::list< Expression * > ctorParameters;
    7484                std::list< Expression * > dtorParameters;
     
    8090                        // for library code are run before constructors and destructors for user code,
    8191                        // specify a priority when building the library. Priorities 0-100 are reserved by gcc.
    82                         // Priorities 101-200 are reserved by cfa, so use priority 200 for CFA library globals,
    83                         // allowing room for overriding with a higher priority.
    84                         ctorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) );
    85                         dtorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) );
     92                        ctorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) );
     93                        dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) );
    8694                }
    87                 initFunction = new FunctionDecl( "__global_init__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
     95                initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
    8896                initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) );
    89                 destroyFunction = new FunctionDecl( "__global_destroy__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
     97                destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
    9098                destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) );
    9199        }
     
    102110                if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
    103111                        // a decision should have been made by the resolver, so ctor and init are not both non-NULL
    104                         assert( ! ctorInit->ctor || ! ctorInit->init );
     112                        assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() );
    105113
    106                         Statement * dtor = ctorInit->dtor;
     114                        Statement * dtor = ctorInit->get_dtor();
    107115                        if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) {
    108116                                // don't need to call intrinsic dtor, because it does nothing, but
    109117                                // non-intrinsic dtors must be called
    110118                                destroyStatements.push_front( dtor );
    111                                 ctorInit->dtor = nullptr;
     119                                ctorInit->set_dtor( NULL );
    112120                        } // if
    113                         if ( Statement * ctor = ctorInit->ctor ) {
     121                        if ( Statement * ctor = ctorInit->get_ctor() ) {
    114122                                initStatements.push_back( ctor );
    115                                 objDecl->init = nullptr;
    116                                 ctorInit->ctor = nullptr;
    117                         } else if ( Initializer * init = ctorInit->init ) {
    118                                 objDecl->init = init;
    119                                 ctorInit->init = nullptr;
     123                                objDecl->set_init( NULL );
     124                                ctorInit->set_ctor( NULL );
     125                        } else if ( Initializer * init = ctorInit->get_init() ) {
     126                                objDecl->set_init( init );
     127                                ctorInit->set_init( NULL );
    120128                        } else {
    121129                                // no constructor and no initializer, which is okay
    122                                 objDecl->init = nullptr;
     130                                objDecl->set_init( NULL );
    123131                        } // if
    124132                        delete ctorInit;
  • src/InitTweak/FixGlobalInit.h

    r9aa9126 r7a7ab42  
    2222
    2323namespace InitTweak {
    24         /// Moves global initialization into an _init function that is unique to the translation unit.
    25         /// Sets the priority of the initialization function depending on whether the initialization
    26         /// function is for library code.
    27         void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary );
     24  /// Moves global initialization into an _init function that is unique to the translation unit.
     25  /// Sets the priority of the initialization function depending on whether the initialization
     26  /// function is for library code.
     27  void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary );
     28
     29  /// Apply transformations to a file name to get a valid C identifier which will be used as
     30  /// the name of the generated initializer function.
     31  std::string globalFunctionName( const std::string & name );
    2832} // namespace
    2933
  • src/InitTweak/FixInit.cc

    r9aa9126 r7a7ab42  
    238238        } // namespace
    239239
    240         void fix( std::list< Declaration * > & translationUnit, bool inLibrary ) {
     240        void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) {
    241241                PassVisitor<SelfAssignChecker> checker;
    242242                acceptAll( translationUnit, checker );
    243243
    244244                // fixes ConstructorInit for global variables. should happen before fixInitializers.
    245                 InitTweak::fixGlobalInit( translationUnit, inLibrary );
     245                InitTweak::fixGlobalInit( translationUnit, filename, inLibrary );
    246246
    247247                UnqCount unqCount;
  • src/InitTweak/FixInit.h

    r9aa9126 r7a7ab42  
    2424  /// replace constructor initializers with expression statements
    2525  /// and unwrap basic C-style initializers
    26         void fix( std::list< Declaration * > & translationUnit, bool inLibrary );
     26        void fix( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary );
    2727} // namespace
    2828
  • src/InitTweak/InitTweak.cc

    r9aa9126 r7a7ab42  
    408408                return allofCtorDtor( stmt, []( Expression * callExpr ){
    409409                        if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) {
    410                                 FunctionType *funcType = GenPoly::getFunctionType( appExpr->function->result );
     410                                FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() );
    411411                                assert( funcType );
    412412                                return funcType->get_parameters().size() == 1;
  • src/Makefile.am

    r9aa9126 r7a7ab42  
    1919
    2020SRC = main.cc \
    21       MakeLibCfa.cc \
    22       CompilationState.cc
     21      MakeLibCfa.cc
    2322
    2423MAINTAINERCLEANFILES =
     
    3837include SynTree/module.mk
    3938include Tuples/module.mk
    40 include Validate/module.mk
    4139include Virtual/module.mk
    4240
  • src/Makefile.in

    r9aa9126 r7a7ab42  
    2323#SRC +=  ArgTweak/Rewriter.cc \
    2424#       ArgTweak/Mutate.cc
    25 
    26 ######################### -*- Mode: Makefile-Gmake -*- ########################
    27 ###############################################################################
    2825
    2926######################### -*- Mode: Makefile-Gmake -*- ########################
     
    153150am__dirstamp = $(am__leading_dot)dirstamp
    154151am__objects_1 = main.$(OBJEXT) MakeLibCfa.$(OBJEXT) \
    155         CompilationState.$(OBJEXT) CodeGen/Generate.$(OBJEXT) \
    156         CodeGen/CodeGenerator.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \
    157         CodeGen/FixNames.$(OBJEXT) CodeGen/FixMain.$(OBJEXT) \
    158         CodeGen/OperatorTable.$(OBJEXT) CodeTools/DeclStats.$(OBJEXT) \
    159         CodeTools/TrackLoc.$(OBJEXT) Concurrency/Keywords.$(OBJEXT) \
    160         Concurrency/Waitfor.$(OBJEXT) Common/SemanticError.$(OBJEXT) \
    161         Common/UniqueName.$(OBJEXT) Common/DebugMalloc.$(OBJEXT) \
    162         Common/Assert.$(OBJEXT) Common/Heap.$(OBJEXT) \
    163         Common/Eval.$(OBJEXT) ControlStruct/LabelGenerator.$(OBJEXT) \
     152        CodeGen/Generate.$(OBJEXT) CodeGen/CodeGenerator.$(OBJEXT) \
     153        CodeGen/GenType.$(OBJEXT) CodeGen/FixNames.$(OBJEXT) \
     154        CodeGen/FixMain.$(OBJEXT) CodeGen/OperatorTable.$(OBJEXT) \
     155        CodeTools/DeclStats.$(OBJEXT) CodeTools/TrackLoc.$(OBJEXT) \
     156        Concurrency/Keywords.$(OBJEXT) Concurrency/Waitfor.$(OBJEXT) \
     157        Common/SemanticError.$(OBJEXT) Common/UniqueName.$(OBJEXT) \
     158        Common/DebugMalloc.$(OBJEXT) Common/Assert.$(OBJEXT) \
     159        Common/Heap.$(OBJEXT) ControlStruct/LabelGenerator.$(OBJEXT) \
    164160        ControlStruct/LabelFixer.$(OBJEXT) \
    165161        ControlStruct/MLEMutator.$(OBJEXT) \
     
    220216        Tuples/TupleAssignment.$(OBJEXT) \
    221217        Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \
    222         Validate/HandleAttributes.$(OBJEXT) \
    223218        Virtual/ExpandCasts.$(OBJEXT)
    224219am____driver_cfa_cpp_OBJECTS = $(am__objects_1)
     
    313308        $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk \
    314309        $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk \
    315         $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk \
    316         $(srcdir)/Virtual/module.mk $(top_srcdir)/automake/depcomp \
    317         $(top_srcdir)/automake/ylwrap Parser/lex.cc Parser/parser.cc \
    318         Parser/parser.hh
     310        $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk \
     311        $(top_srcdir)/automake/depcomp $(top_srcdir)/automake/ylwrap \
     312        Parser/lex.cc Parser/parser.cc Parser/parser.hh
    319313DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    320314ACLOCAL = @ACLOCAL@
     
    446440# create object files in directory with source files
    447441AUTOMAKE_OPTIONS = subdir-objects
    448 SRC = main.cc MakeLibCfa.cc CompilationState.cc CodeGen/Generate.cc \
     442SRC = main.cc MakeLibCfa.cc CodeGen/Generate.cc \
    449443        CodeGen/CodeGenerator.cc CodeGen/GenType.cc \
    450444        CodeGen/FixNames.cc CodeGen/FixMain.cc \
     
    453447        Concurrency/Waitfor.cc Common/SemanticError.cc \
    454448        Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \
    455         Common/Heap.cc Common/Eval.cc ControlStruct/LabelGenerator.cc \
     449        Common/Heap.cc ControlStruct/LabelGenerator.cc \
    456450        ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \
    457451        ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \
     
    495489        SynTree/Attribute.cc SynTree/DeclReplacer.cc \
    496490        Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
    497         Tuples/Explode.cc Validate/HandleAttributes.cc \
    498         Virtual/ExpandCasts.cc
     491        Tuples/Explode.cc Virtual/ExpandCasts.cc
    499492MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    500493        ${cfa_cpplib_PROGRAMS}}
     
    515508.SUFFIXES:
    516509.SUFFIXES: .cc .ll .o .obj .yy
    517 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps)
     510$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps)
    518511        @for dep in $?; do \
    519512          case '$(am__configure_deps)' in \
     
    535528            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    536529        esac;
    537 $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__empty):
     530$(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk $(am__empty):
    538531
    539532$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
     
    640633        Common/$(DEPDIR)/$(am__dirstamp)
    641634Common/Heap.$(OBJEXT): Common/$(am__dirstamp) \
    642         Common/$(DEPDIR)/$(am__dirstamp)
    643 Common/Eval.$(OBJEXT): Common/$(am__dirstamp) \
    644635        Common/$(DEPDIR)/$(am__dirstamp)
    645636ControlStruct/$(am__dirstamp):
     
    873864Tuples/Explode.$(OBJEXT): Tuples/$(am__dirstamp) \
    874865        Tuples/$(DEPDIR)/$(am__dirstamp)
    875 Validate/$(am__dirstamp):
    876         @$(MKDIR_P) Validate
    877         @: > Validate/$(am__dirstamp)
    878 Validate/$(DEPDIR)/$(am__dirstamp):
    879         @$(MKDIR_P) Validate/$(DEPDIR)
    880         @: > Validate/$(DEPDIR)/$(am__dirstamp)
    881 Validate/HandleAttributes.$(OBJEXT): Validate/$(am__dirstamp) \
    882         Validate/$(DEPDIR)/$(am__dirstamp)
    883866Virtual/$(am__dirstamp):
    884867        @$(MKDIR_P) Virtual
     
    911894        -rm -f SynTree/*.$(OBJEXT)
    912895        -rm -f Tuples/*.$(OBJEXT)
    913         -rm -f Validate/*.$(OBJEXT)
    914896        -rm -f Virtual/*.$(OBJEXT)
    915897
     
    917899        -rm -f *.tab.c
    918900
    919 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CompilationState.Po@am__quote@
    920901@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MakeLibCfa.Po@am__quote@
    921902@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
     
    930911@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Assert.Po@am__quote@
    931912@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/DebugMalloc.Po@am__quote@
    932 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Eval.Po@am__quote@
    933913@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Heap.Po@am__quote@
    934914@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/SemanticError.Po@am__quote@
     
    10251005@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/TupleAssignment.Po@am__quote@
    10261006@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/TupleExpansion.Po@am__quote@
    1027 @AMDEP_TRUE@@am__include@ @am__quote@Validate/$(DEPDIR)/HandleAttributes.Po@am__quote@
    10281007@AMDEP_TRUE@@am__include@ @am__quote@Virtual/$(DEPDIR)/ExpandCasts.Po@am__quote@
    10291008
     
    11921171        -rm -f Tuples/$(DEPDIR)/$(am__dirstamp)
    11931172        -rm -f Tuples/$(am__dirstamp)
    1194         -rm -f Validate/$(DEPDIR)/$(am__dirstamp)
    1195         -rm -f Validate/$(am__dirstamp)
    11961173        -rm -f Virtual/$(DEPDIR)/$(am__dirstamp)
    11971174        -rm -f Virtual/$(am__dirstamp)
     
    12101187
    12111188distclean: distclean-am
    1212         -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR)
     1189        -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Virtual/$(DEPDIR)
    12131190        -rm -f Makefile
    12141191distclean-am: clean-am distclean-compile distclean-generic \
     
    12561233
    12571234maintainer-clean: maintainer-clean-am
    1258         -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR)
     1235        -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Virtual/$(DEPDIR)
    12591236        -rm -f Makefile
    12601237maintainer-clean-am: distclean-am maintainer-clean-generic
  • src/Parser/ParseNode.h

    r9aa9126 r7a7ab42  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  4 09:39:40 2018
    13 // Update Count     : 853
     12// Last Modified On : Fri Jul 20 14:56:30 2018
     13// Update Count     : 850
    1414//
    1515
     
    132132        void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}
    133133
    134         Expression *get_expr() const { return expr.get(); }
    135134        template<typename T>
    136135        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
     
    391390Statement * build_expr( ExpressionNode * ctl );
    392391
    393 struct IfCtrl {
    394         IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) :
     392struct IfCtl {
     393        IfCtl( DeclarationNode * decl, ExpressionNode * condition ) :
    395394                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
    396395
     
    399398};
    400399
    401 struct ForCtrl {
    402         ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
     400struct ForCtl {
     401        ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
    403402                init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    404         ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
     403        ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
    405404                init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
    406405
     
    410409};
    411410
    412 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init );
    413 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
     411Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init );
     412Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    414413Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    415414Statement * build_case( ExpressionNode * ctl );
    416415Statement * build_default();
    417 Statement * build_while( IfCtrl * ctl, StatementNode * stmt );
     416Statement * build_while( IfCtl * ctl, StatementNode * stmt );
    418417Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt );
    419 Statement * build_for( ForCtrl * forctl, StatementNode * stmt );
     418Statement * build_for( ForCtl * forctl, StatementNode * stmt );
    420419Statement * build_branch( BranchStmt::Type kind );
    421420Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
  • src/Parser/StatementNode.cc

    r9aa9126 r7a7ab42  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  4 09:39:25 2018
    13 // Update Count     : 363
     12// Last Modified On : Tue Jun  5 08:58:34 2018
     13// Update Count     : 362
    1414//
    1515
     
    7878} // build_expr
    7979
    80 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init ) {
     80Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init ) {
    8181        if ( ctl->init != 0 ) {
    8282                buildMoveList( ctl->init, init );
     
    100100} // build_if_control
    101101
    102 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
     102Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
    103103        Statement * thenb, * elseb = nullptr;
    104104        std::list< Statement * > branches;
     
    145145} // build_default
    146146
    147 Statement * build_while( IfCtrl * ctl, StatementNode * stmt ) {
     147Statement * build_while( IfCtl * ctl, StatementNode * stmt ) {
    148148        std::list< Statement * > branches;
    149149        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    164164} // build_do_while
    165165
    166 Statement * build_for( ForCtrl * forctl, StatementNode * stmt ) {
     166Statement * build_for( ForCtl * forctl, StatementNode * stmt ) {
    167167        std::list< Statement * > branches;
    168168        buildMoveList< Statement, StatementNode >( stmt, branches );
  • src/Parser/lex.ll

    r9aa9126 r7a7ab42  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed Aug  8 17:23:17 2018
    13  * Update Count     : 685
     12 * Last Modified On : Wed Jun 20 09:08:28 2018
     13 * Update Count     : 682
    1414 */
    1515
     
    410410">>="                   { NAMEDOP_RETURN(RSassign); }
    411411
    412 "~="                    { NAMEDOP_RETURN(Erange); }                             // CFA
    413412"@="                    { NAMEDOP_RETURN(ATassign); }                   // CFA
    414413
  • src/Parser/parser.yy

    r9aa9126 r7a7ab42  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  8 17:50:07 2018
    13 // Update Count     : 3998
     12// Last Modified On : Wed Jul 25 15:54:35 2018
     13// Update Count     : 3841
    1414//
    1515
     
    186186} // fieldDecl
    187187
    188 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    189         return new ForCtrl(
    190                 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
    191                 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
    192                 new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) );
    193 } // forCtrl
    194 
    195 
    196188bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    197189
     
    225217        WaitForStmt * wfs;
    226218        Expression * constant;
    227         IfCtrl * ifctl;
    228         ForCtrl * fctl;
    229         enum OperKinds compop;
     219        IfCtl * ifctl;
     220        ForCtl * fctl;
    230221        LabelNode * label;
    231222        InitializerNode * in;
     
    290281%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    291282
    292 %token Erange                                                                                   // ~=
    293283%token ATassign                                                                                 // @=
    294284
     
    313303%type<ifctl> if_control_expression
    314304%type<fctl> for_control_expression
    315 %type<compop> inclexcl
    316305%type<en> subrange
    317306%type<decl> asm_name_opt
     
    10601049if_control_expression:
    10611050        comma_expression
    1062                 { $$ = new IfCtrl( nullptr, $1 ); }
     1051                { $$ = new IfCtl( nullptr, $1 ); }
    10631052        | c_declaration                                                                         // no semi-colon
    1064                 { $$ = new IfCtrl( $1, nullptr ); }
     1053                { $$ = new IfCtl( $1, nullptr ); }
    10651054        | cfa_declaration                                                                       // no semi-colon
    1066                 { $$ = new IfCtrl( $1, nullptr ); }
     1055                { $$ = new IfCtl( $1, nullptr ); }
    10671056        | declaration comma_expression                                          // semi-colon separated
    1068                 { $$ = new IfCtrl( $1, $2 ); }
     1057                { $$ = new IfCtl( $1, $2 ); }
    10691058        ;
    10701059
     
    11221111        WHILE '(' push if_control_expression ')' statement pop
    11231112                { $$ = new StatementNode( build_while( $4, $6 ) ); }
    1124         | WHILE '(' ')' statement                                                       // CFA => while ( 1 )
    1125                 { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), $4 ) ); }
    11261113        | DO statement WHILE '(' comma_expression ')' ';'
    11271114                { $$ = new StatementNode( build_do_while( $5, $2 ) ); }
    1128         | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    1129                 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); }
    11301115        | FOR '(' push for_control_expression ')' statement pop
    11311116                { $$ = new StatementNode( build_for( $4, $6 ) ); }
     
    11331118
    11341119for_control_expression:
    1135         comma_expression_opt                                                            // CFA
    1136                 {
    1137                         if ( ! $1 ) {                                                           // => for ( ;; )
    1138                                 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr );
    1139                         } else {
    1140                                 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $1->clone(),
    1141                                                          new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    1142                         } // if
    1143                 }
    1144         | constant_expression inclexcl constant_expression      // CFA
    1145                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1146         | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    1147                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
    1148         | comma_expression_opt ';' comma_expression                     // CFA
    1149                 {
    1150                         if ( ! $1 ) {
    1151                                 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
    1152                         } else if ( ! $3 ) {
    1153                                 SemanticError( yylloc, "Missing loop range." ); $$ = nullptr;
    1154                         } else {
    1155                                 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1156                                         $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $3->clone(),
    1157                                                                  new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    1158                                 } else {
    1159                                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
    1160                                 } // if
    1161                         } // if
    1162                 }
    1163         | comma_expression_opt ';' constant_expression inclexcl constant_expression // CFA
    1164                 {
    1165                         if ( ! $1 ) {
    1166                                 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
    1167                         } else {
    1168                                 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1169                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    1170                                 } else {
    1171                                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
    1172                                 } // if
    1173                         } // if
    1174                 }
    1175         | comma_expression_opt ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA
    1176                 {
    1177                         if ( ! $1 ) {
    1178                                 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
    1179                         } else {
    1180                                 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1181                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, $7 );
    1182                                 } else {
    1183                                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
    1184                                 } // if
    1185                         } // if
    1186                 }
    1187         | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
    1188                 { $$ = new ForCtrl( $1, $3, $5 ); }
    1189         | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    1190                 { $$ = new ForCtrl( $1, $2, $4 ); }
    1191         ;
    1192 
    1193 inclexcl:
    1194         '~'
    1195                 { $$ = OperKinds::LThan; }
    1196         | Erange
    1197                 { $$ = OperKinds::LEThan; }
     1120        comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
     1121                { $$ = new ForCtl( $1, $3, $5 ); }
     1122        | declaration comma_expression_opt ';' comma_expression_opt // C99
     1123                { $$ = new ForCtl( $1, $2, $4 ); }
    11981124        ;
    11991125
  • src/ResolvExpr/CurrentObject.cc

    r9aa9126 r7a7ab42  
    139139                ArrayIterator( ArrayType * at ) : array( at ) {
    140140                        PRINT( std::cerr << "Creating array iterator: " << at << std::endl; )
    141                         base = at->base;
     141                        base = at->get_base();
    142142                        memberIter = createMemberIterator( base );
    143                         if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=: " );
    144                         setSize( at->dimension );
     143                        if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=" );
     144                        setSize( at->get_dimension() );
    145145                }
    146146
     
    150150
    151151        private:
    152                 void setSize( Expression * expr ) { // replace this logic with an eval call
    153                         auto res = eval(expr);
    154                         if (res.second) {
    155                                 size = res.first;
     152                void setSize( Expression * expr ) {
     153                        if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
     154                                try {
     155                                        size = constExpr->intValue();
     156                                        PRINT( std::cerr << "array type with size: " << size << std::endl; )
     157                                } catch ( SemanticErrorException & ) {
     158                                        SemanticError( expr, "Constant expression of non-integral type in array dimension: " );
     159                                }
     160                        }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
     161                                setSize( castExpr->get_arg() ); // xxx - need to perform the conversion specified by the cast
     162                        } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
     163                                if ( EnumInstType * inst = dynamic_cast< EnumInstType * > ( varExpr->result ) ) {
     164                                        long long int value;
     165                                        if ( inst->baseEnum->valueOf( varExpr->var, value ) ) {
     166                                                size = value;
     167                                        }
     168                                }
    156169                        } else {
    157                                 SemanticError( expr->location, toString("Array designator must be a constant expression: ", expr) );
     170                                assertf( false, "unhandled expression in setSize: %s", toString( expr ).c_str() ); // xxx - if not a constant expression, it's not simple to determine how long the array actually is, which is necessary for initialization to be done correctly -- fix this
    158171                        }
    159172                }
  • src/SymTab/Validate.cc

    r9aa9126 r7a7ab42  
    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;
     
    249247        };
    250248
    251         struct ArrayLength : public WithIndexer {
     249        struct ArrayLength {
    252250                /// for array types without an explicit length, compute the length and store it so that it
    253251                /// is known to the rest of the phases. For example,
     
    260258
    261259                void previsit( ObjectDecl * objDecl );
    262                 void previsit( ArrayType * arrayType );
    263260        };
    264261
     
    315312                acceptAll( translationUnit, finder ); // xxx - remove this pass soon
    316313                mutateAll( translationUnit, labelAddrFixer );
    317                 Validate::handleAttributes( translationUnit );
    318314        }
    319315
     
    738734                                forwardEnums.erase( fwds );
    739735                        } // 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                         }
    749736                } // if
    750737        }
     
    12451232        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    12461233                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    1247                         if ( at->dimension ) return;
     1234                        if ( at->get_dimension() ) return;
    12481235                        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 );
     1236                                at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) );
     1237                        }
    12631238                }
    12641239        }
  • src/SynTree/AggregateDecl.cc

    r9aa9126 r7a7ab42  
    8686std::string TraitDecl::typeString() const { return "trait"; }
    8787
     88namespace {
     89        long long int getConstValue( Expression * expr ) {
     90                if ( CastExpr * castExpr = dynamic_cast< CastExpr * > ( expr ) ) {
     91                        return getConstValue( castExpr->arg );
     92                } else if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
     93                        return constExpr->intValue();
     94                // can be -1, +1, etc.
     95                // } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( expr ) ) {
     96                //      if ( untypedExpr-> )
     97                } else {
     98                        assertf( false, "Unhandled expression type in getConstValue for enumerators: %s", toString( expr ).c_str() );
     99                }
     100        }
     101}
     102
    88103bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) {
    89104        if ( enumValues.empty() ) {
     
    93108                        if ( field->init ) {
    94109                                SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init );
    95                                 auto result = eval( init->value );
    96                                 if ( ! result.second ) SemanticError( init->location, toString( "Non-constexpr in initialization of enumerator: ", field ) );
    97                                 currentValue = result.first;
     110                                currentValue = getConstValue( init->value );
    98111                        }
    99112                        assertf( enumValues.count( field->name ) == 0, "Enum %s has multiple members with the name %s", name.c_str(), field->name.c_str() );
  • src/main.cc

    r9aa9126 r7a7ab42  
    2828#include <string>                           // for char_traits, operator<<
    2929
    30 #include "CompilationState.h"
    3130#include "../config.h"                      // for CFA_LIBDIR
    3231#include "CodeGen/FixMain.h"                // for FixMain
     
    7372DeclarationNode * parseTree = nullptr;                                  // program parse tree
    7473
     74extern int yydebug;                                                                             // set for -g flag (Grammar)
     75bool
     76        astp = false,
     77        bresolvep = false,
     78        bboxp = false,
     79        bcodegenp = false,
     80        ctorinitp = false,
     81        declstatsp = false,
     82        exprp = false,
     83        expraltp = false,
     84        genericsp = false,
     85        libcfap = false,
     86        nopreludep = false,
     87        noprotop = false,
     88        nomainp = false,
     89        parsep = false,
     90        resolvep = false,                                                                       // used in AlternativeFinder
     91        symtabp = false,
     92        treep = false,
     93        tuplep = false,
     94        validp = false,
     95        errorp = false,
     96        codegenp = false,
     97        prettycodegenp = false,
     98        linemarks = false;
     99
    75100std::string PreludeDirector = "";
    76101
     
    278303
    279304                // fix ObjectDecl - replaces ConstructorInit nodes
    280                 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );
     305                PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
    281306                if ( ctorinitp ) {
    282307                        dump ( translationUnit );
  • tests/.expect/attributes.x64.txt

    r9aa9126 r7a7ab42  
    316316    ((void)sizeof(__attribute__ ((unused,unused)) signed int ));
    317317    ((void)sizeof(__attribute__ ((unused,unused,unused,unused)) signed int **));
    318     ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [((unsigned long int )5)]));
    319     ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[((unsigned long int )10)]));
     318    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [5]));
     319    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10]));
    320320    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ()));
    321321    struct __attribute__ ((unused)) __anonymous3 {
  • tests/.expect/attributes.x86.txt

    r9aa9126 r7a7ab42  
    316316    ((void)sizeof(__attribute__ ((unused,unused)) signed int ));
    317317    ((void)sizeof(__attribute__ ((unused,unused,unused,unused)) signed int **));
    318     ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [((unsigned int )5)]));
    319     ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[((unsigned int )10)]));
     318    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [5]));
     319    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10]));
    320320    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ()));
    321321    struct __attribute__ ((unused)) __anonymous3 {
  • tests/function-operator.c

    r9aa9126 r7a7ab42  
    1010// Created On       : Fri Aug 25 15:21:11 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  2 09:27:53 2018
    13 // Update Count     : 8
     12// Last Modified On : Thu Dec  7 12:42:26 2017
     13// Update Count     : 6
    1414//
    1515
     
    9292void ?{}(ostream_iterator & iter, ofstream * out) {
    9393        iter.out = new(out);
    94 }
     94                }
    9595// no destructor, memory leak. This is necessary for this to work at the moment, since
    9696// *? requires its parameter by value and returns a reference.
     
    168168        transform(begin(x), end(x), begin(x), &times2);
    169169        copy(begin(x), end(x), out_iter);
    170 
    171         // REMOVE WHEN ?* PROBLEM FIXED.
    172         delete(out_iter.out);
    173170}
    174171
  • tests/sum.c

    r9aa9126 r7a7ab42  
    1111// Created On       : Wed May 27 17:56:53 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu Aug  2 08:03:09 2018
    14 // Update Count     : 279
     13// Last Modified On : Sun Jun  3 19:23:41 2018
     14// Update Count     : 278
    1515//
    1616
     
    115115        sout | "sum from" | low | "to" | High | "is"
    116116                 | sum( size, gs.x ) | ", check" | (int)s | endl; // add field array in generic type
    117         delete( gs.x );
    118117} // main
    119118
  • tests/tuple/tupleVariadic.c

    r9aa9126 r7a7ab42  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri Dec 16 10:25:35 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  2 09:24:04 2018
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Dec 21 14:42:48 2016
     13// Update Count     : 2
    1414//
    15 
    16 #include <stdlib>
    1715
    1816void func(void) {
     
    3028        printf("called process(double) %g\n", x);
    3129}
     30
     31forall( dtype T, ttype Params | sized(T) | { void ?{}(T &, Params); } )
     32T * new(Params p);
    3233
    3334struct array {
     
    6566        a.data[2] = a2;
    6667        printf("called ?{} with a: %d %d %d\n", a0, a1, a2);
    67 }
    68 
    69 void ^?{}(array & a) {
    70         free(a.data);
    7168}
    7269
     
    129126                bar(x);
    130127        }
    131 
    132         delete(ptr);
    133         delete(x4);
    134         delete(x3);
    135         delete(x2);
    136         delete(x1);
    137         delete(x0);
    138128}
    139129
     
    141131// tab-width: 4 //
    142132// End: //
     133
Note: See TracChangeset for help on using the changeset viewer.