Changeset 9aa9126


Ignore:
Timestamp:
Aug 9, 2018, 1:14:24 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
fc846ae
Parents:
7a7ab42 (diff), 3b2b37f (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
7 added
32 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

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

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

    r7a7ab42 r9aa9126  
    9393host_triplet = @host@
    9494noinst_PROGRAMS = cfa$(EXEEXT)
    95 cc1lib_PROGRAMS = cc1$(EXEEXT)
     95cc1lib_PROGRAMS = as$(EXEEXT) cc1$(EXEEXT)
    9696subdir = driver
    9797ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
     
    107107am__installdirs = "$(DESTDIR)$(cc1libdir)"
    108108PROGRAMS = $(cc1lib_PROGRAMS) $(noinst_PROGRAMS)
     109am_as_OBJECTS = as.$(OBJEXT)
     110as_OBJECTS = $(am_as_OBJECTS)
     111as_LDADD = $(LDADD)
    109112am_cc1_OBJECTS = cc1.$(OBJEXT)
    110113cc1_OBJECTS = $(am_cc1_OBJECTS)
     
    142145am__v_CXXLD_0 = @echo "  CXXLD   " $@;
    143146am__v_CXXLD_1 =
    144 SOURCES = $(cc1_SOURCES) $(cfa_SOURCES)
    145 DIST_SOURCES = $(cc1_SOURCES) $(cfa_SOURCES)
     147SOURCES = $(as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES)
     148DIST_SOURCES = $(as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES)
    146149am__can_run_installinfo = \
    147150  case $$AM_UPDATE_INFO_DIR in \
     
    302305# put into lib for now
    303306cc1libdir = ${CFA_LIBDIR}
     307as_SOURCES = as.cc
    304308cc1_SOURCES = cc1.cc
    305 
    306 # cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT)
    307 #       cp $(<) $(@)
    308309MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS}
    309310all: all-am
     
    386387        -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
    387388
     389as$(EXEEXT): $(as_OBJECTS) $(as_DEPENDENCIES) $(EXTRA_as_DEPENDENCIES)
     390        @rm -f as$(EXEEXT)
     391        $(AM_V_CXXLD)$(CXXLINK) $(as_OBJECTS) $(as_LDADD) $(LIBS)
     392
    388393cc1$(EXEEXT): $(cc1_OBJECTS) $(cc1_DEPENDENCIES) $(EXTRA_cc1_DEPENDENCIES)
    389394        @rm -f cc1$(EXEEXT)
     
    400405        -rm -f *.tab.c
    401406
     407@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/as.Po@am__quote@
    402408@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc1.Po@am__quote@
    403409@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfa.Po@am__quote@
  • driver/cfa.cc

    r7a7ab42 r9aa9126  
    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;
    404408
    405409                // include the cfa library in case it's needed
  • libcfa/prelude/builtins.c

    r7a7ab42 r9aa9126  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 12:47:59 2018
    13 // Update Count     : 19
     12// Last Modified On : Sun Aug  5 21:40:38 2018
     13// Update Count     : 20
    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

    r7a7ab42 r9aa9126  
    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
    6672        }
    6773
     
    7177                this.lock = 0;
    7278        }
    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
    8079
    8180        // Lock the spinlock, return false if already acquired
  • libcfa/src/concurrency/kernel.cfa

    r7a7ab42 r9aa9126  
    833833// Debug
    834834__cfaabi_dbg_debug_do(
    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;
     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                }
    838840        }
    839841)
  • libcfa/src/startup.cfa

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

    r7a7ab42 r9aa9126  
    2727namespace CodeGen {
    2828        struct GenType : public WithVisitorRef<GenType>, public WithShortCircuiting {
    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; }
     29                std::string typeString;
     30                GenType( const std::string &typeString, bool pretty, bool genC, bool lineMarks );
    3231
    3332                void previsit( BaseSyntaxNode * );
     
    5857                void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
    5958
    60                 std::string typeString;
    61                 bool pretty = false; // pretty print
    62                 bool genC = false;   // generating C code?
    63                 bool lineMarks = false;
     59                bool pretty = false;    // pretty print
     60                bool genC = false;      // generating C code?
     61                bool lineMarks = false; // lineMarks on for CodeGenerator?
    6462        };
    6563
     
    7472
    7573                type->accept( gt );
    76                 return os.str() + gt.pass.get_typeString();
     74                return os.str() + gt.pass.typeString;
    7775        }
    7876
  • src/Common/SemanticError.h

    r7a7ab42 r9aa9126  
    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},
    6061};
    6162
     
    6667        AggrForwardDecl,
    6768        SuperfluousDecl,
     69        GccAttributes,
    6870        NUMBER_OF_WARNINGS, // This MUST be the last warning
    6971};
  • src/Common/module.mk

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

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

    r7a7ab42 r9aa9126  
    3737        class GlobalFixer : public WithShortCircuiting {
    3838          public:
    39                 GlobalFixer( const std::string & name, bool inLibrary );
     39                GlobalFixer( bool inLibrary );
    4040
    4141                void previsit( ObjectDecl *objDecl );
     
    5252        };
    5353
    54         void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ) {
    55                 PassVisitor<GlobalFixer> visitor( name, inLibrary );
     54        void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary ) {
     55                PassVisitor<GlobalFixer> visitor( inLibrary );
    5656                acceptAll( translationUnit, visitor );
    5757                GlobalFixer & fixer = visitor.pass;
     
    7070        }
    7171
    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 );
     72        GlobalFixer::GlobalFixer( bool inLibrary ) : tempNamer( "_global_init" ) {
    8373                std::list< Expression * > ctorParameters;
    8474                std::list< Expression * > dtorParameters;
     
    9080                        // for library code are run before constructors and destructors for user code,
    9181                        // specify a priority when building the library. Priorities 0-100 are reserved by gcc.
    92                         ctorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) );
    93                         dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) );
     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 ) ) );
    9486                }
    95                 initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
     87                initFunction = new FunctionDecl( "__global_init__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
    9688                initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) );
    97                 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
     89                destroyFunction = new FunctionDecl( "__global_destroy__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
    9890                destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) );
    9991        }
     
    110102                if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
    111103                        // a decision should have been made by the resolver, so ctor and init are not both non-NULL
    112                         assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() );
     104                        assert( ! ctorInit->ctor || ! ctorInit->init );
    113105
    114                         Statement * dtor = ctorInit->get_dtor();
     106                        Statement * dtor = ctorInit->dtor;
    115107                        if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) {
    116108                                // don't need to call intrinsic dtor, because it does nothing, but
    117109                                // non-intrinsic dtors must be called
    118110                                destroyStatements.push_front( dtor );
    119                                 ctorInit->set_dtor( NULL );
     111                                ctorInit->dtor = nullptr;
    120112                        } // if
    121                         if ( Statement * ctor = ctorInit->get_ctor() ) {
     113                        if ( Statement * ctor = ctorInit->ctor ) {
    122114                                initStatements.push_back( ctor );
    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 );
     115                                objDecl->init = nullptr;
     116                                ctorInit->ctor = nullptr;
     117                        } else if ( Initializer * init = ctorInit->init ) {
     118                                objDecl->init = init;
     119                                ctorInit->init = nullptr;
    128120                        } else {
    129121                                // no constructor and no initializer, which is okay
    130                                 objDecl->set_init( NULL );
     122                                objDecl->init = nullptr;
    131123                        } // if
    132124                        delete ctorInit;
  • src/InitTweak/FixGlobalInit.h

    r7a7ab42 r9aa9126  
    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, 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 );
     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 );
    3228} // namespace
    3329
  • src/InitTweak/FixInit.cc

    r7a7ab42 r9aa9126  
    238238        } // namespace
    239239
    240         void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) {
     240        void fix( std::list< Declaration * > & translationUnit, 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, filename, inLibrary );
     245                InitTweak::fixGlobalInit( translationUnit, inLibrary );
    246246
    247247                UnqCount unqCount;
  • src/InitTweak/FixInit.h

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

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

    r7a7ab42 r9aa9126  
    1919
    2020SRC = main.cc \
    21       MakeLibCfa.cc
     21      MakeLibCfa.cc \
     22      CompilationState.cc
    2223
    2324MAINTAINERCLEANFILES =
     
    3738include SynTree/module.mk
    3839include Tuples/module.mk
     40include Validate/module.mk
    3941include Virtual/module.mk
    4042
  • src/Makefile.in

    r7a7ab42 r9aa9126  
    2323#SRC +=  ArgTweak/Rewriter.cc \
    2424#       ArgTweak/Mutate.cc
     25
     26######################### -*- Mode: Makefile-Gmake -*- ########################
     27###############################################################################
    2528
    2629######################### -*- Mode: Makefile-Gmake -*- ########################
     
    150153am__dirstamp = $(am__leading_dot)dirstamp
    151154am__objects_1 = main.$(OBJEXT) MakeLibCfa.$(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) \
     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) \
    160164        ControlStruct/LabelFixer.$(OBJEXT) \
    161165        ControlStruct/MLEMutator.$(OBJEXT) \
     
    216220        Tuples/TupleAssignment.$(OBJEXT) \
    217221        Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \
     222        Validate/HandleAttributes.$(OBJEXT) \
    218223        Virtual/ExpandCasts.$(OBJEXT)
    219224am____driver_cfa_cpp_OBJECTS = $(am__objects_1)
     
    308313        $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk \
    309314        $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk \
    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
     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
    313319DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    314320ACLOCAL = @ACLOCAL@
     
    440446# create object files in directory with source files
    441447AUTOMAKE_OPTIONS = subdir-objects
    442 SRC = main.cc MakeLibCfa.cc CodeGen/Generate.cc \
     448SRC = main.cc MakeLibCfa.cc CompilationState.cc CodeGen/Generate.cc \
    443449        CodeGen/CodeGenerator.cc CodeGen/GenType.cc \
    444450        CodeGen/FixNames.cc CodeGen/FixMain.cc \
     
    447453        Concurrency/Waitfor.cc Common/SemanticError.cc \
    448454        Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \
    449         Common/Heap.cc ControlStruct/LabelGenerator.cc \
     455        Common/Heap.cc Common/Eval.cc ControlStruct/LabelGenerator.cc \
    450456        ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \
    451457        ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \
     
    489495        SynTree/Attribute.cc SynTree/DeclReplacer.cc \
    490496        Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
    491         Tuples/Explode.cc Virtual/ExpandCasts.cc
     497        Tuples/Explode.cc Validate/HandleAttributes.cc \
     498        Virtual/ExpandCasts.cc
    492499MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    493500        ${cfa_cpplib_PROGRAMS}}
     
    508515.SUFFIXES:
    509516.SUFFIXES: .cc .ll .o .obj .yy
    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)
     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)
    511518        @for dep in $?; do \
    512519          case '$(am__configure_deps)' in \
     
    528535            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    529536        esac;
    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):
     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):
    531538
    532539$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
     
    633640        Common/$(DEPDIR)/$(am__dirstamp)
    634641Common/Heap.$(OBJEXT): Common/$(am__dirstamp) \
     642        Common/$(DEPDIR)/$(am__dirstamp)
     643Common/Eval.$(OBJEXT): Common/$(am__dirstamp) \
    635644        Common/$(DEPDIR)/$(am__dirstamp)
    636645ControlStruct/$(am__dirstamp):
     
    864873Tuples/Explode.$(OBJEXT): Tuples/$(am__dirstamp) \
    865874        Tuples/$(DEPDIR)/$(am__dirstamp)
     875Validate/$(am__dirstamp):
     876        @$(MKDIR_P) Validate
     877        @: > Validate/$(am__dirstamp)
     878Validate/$(DEPDIR)/$(am__dirstamp):
     879        @$(MKDIR_P) Validate/$(DEPDIR)
     880        @: > Validate/$(DEPDIR)/$(am__dirstamp)
     881Validate/HandleAttributes.$(OBJEXT): Validate/$(am__dirstamp) \
     882        Validate/$(DEPDIR)/$(am__dirstamp)
    866883Virtual/$(am__dirstamp):
    867884        @$(MKDIR_P) Virtual
     
    894911        -rm -f SynTree/*.$(OBJEXT)
    895912        -rm -f Tuples/*.$(OBJEXT)
     913        -rm -f Validate/*.$(OBJEXT)
    896914        -rm -f Virtual/*.$(OBJEXT)
    897915
     
    899917        -rm -f *.tab.c
    900918
     919@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CompilationState.Po@am__quote@
    901920@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MakeLibCfa.Po@am__quote@
    902921@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
     
    911930@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Assert.Po@am__quote@
    912931@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@
    913933@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Heap.Po@am__quote@
    914934@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/SemanticError.Po@am__quote@
     
    10051025@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/TupleAssignment.Po@am__quote@
    10061026@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@
    10071028@AMDEP_TRUE@@am__include@ @am__quote@Virtual/$(DEPDIR)/ExpandCasts.Po@am__quote@
    10081029
     
    11711192        -rm -f Tuples/$(DEPDIR)/$(am__dirstamp)
    11721193        -rm -f Tuples/$(am__dirstamp)
     1194        -rm -f Validate/$(DEPDIR)/$(am__dirstamp)
     1195        -rm -f Validate/$(am__dirstamp)
    11731196        -rm -f Virtual/$(DEPDIR)/$(am__dirstamp)
    11741197        -rm -f Virtual/$(am__dirstamp)
     
    11871210
    11881211distclean: distclean-am
    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)
     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)
    11901213        -rm -f Makefile
    11911214distclean-am: clean-am distclean-compile distclean-generic \
     
    12331256
    12341257maintainer-clean: maintainer-clean-am
    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)
     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)
    12361259        -rm -f Makefile
    12371260maintainer-clean-am: distclean-am maintainer-clean-generic
  • src/Parser/ParseNode.h

    r7a7ab42 r9aa9126  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 20 14:56:30 2018
    13 // Update Count     : 850
     12// Last Modified On : Sat Aug  4 09:39:40 2018
     13// Update Count     : 853
    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(); }
    134135        template<typename T>
    135136        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
     
    390391Statement * build_expr( ExpressionNode * ctl );
    391392
    392 struct IfCtl {
    393         IfCtl( DeclarationNode * decl, ExpressionNode * condition ) :
     393struct IfCtrl {
     394        IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) :
    394395                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
    395396
     
    398399};
    399400
    400 struct ForCtl {
    401         ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
     401struct ForCtrl {
     402        ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
    402403                init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    403         ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
     404        ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
    404405                init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
    405406
     
    409410};
    410411
    411 Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init );
    412 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
     412Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init );
     413Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    413414Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    414415Statement * build_case( ExpressionNode * ctl );
    415416Statement * build_default();
    416 Statement * build_while( IfCtl * ctl, StatementNode * stmt );
     417Statement * build_while( IfCtrl * ctl, StatementNode * stmt );
    417418Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt );
    418 Statement * build_for( ForCtl * forctl, StatementNode * stmt );
     419Statement * build_for( ForCtrl * forctl, StatementNode * stmt );
    419420Statement * build_branch( BranchStmt::Type kind );
    420421Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
  • src/Parser/StatementNode.cc

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

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

    r7a7ab42 r9aa9126  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 25 15:54:35 2018
    13 // Update Count     : 3841
     12// Last Modified On : Wed Aug  8 17:50:07 2018
     13// Update Count     : 3998
    1414//
    1515
     
    186186} // fieldDecl
    187187
     188ForCtrl * 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
    188196bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    189197
     
    217225        WaitForStmt * wfs;
    218226        Expression * constant;
    219         IfCtl * ifctl;
    220         ForCtl * fctl;
     227        IfCtrl * ifctl;
     228        ForCtrl * fctl;
     229        enum OperKinds compop;
    221230        LabelNode * label;
    222231        InitializerNode * in;
     
    281290%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    282291
     292%token Erange                                                                                   // ~=
    283293%token ATassign                                                                                 // @=
    284294
     
    303313%type<ifctl> if_control_expression
    304314%type<fctl> for_control_expression
     315%type<compop> inclexcl
    305316%type<en> subrange
    306317%type<decl> asm_name_opt
     
    10491060if_control_expression:
    10501061        comma_expression
    1051                 { $$ = new IfCtl( nullptr, $1 ); }
     1062                { $$ = new IfCtrl( nullptr, $1 ); }
    10521063        | c_declaration                                                                         // no semi-colon
    1053                 { $$ = new IfCtl( $1, nullptr ); }
     1064                { $$ = new IfCtrl( $1, nullptr ); }
    10541065        | cfa_declaration                                                                       // no semi-colon
    1055                 { $$ = new IfCtl( $1, nullptr ); }
     1066                { $$ = new IfCtrl( $1, nullptr ); }
    10561067        | declaration comma_expression                                          // semi-colon separated
    1057                 { $$ = new IfCtl( $1, $2 ); }
     1068                { $$ = new IfCtrl( $1, $2 ); }
    10581069        ;
    10591070
     
    11111122        WHILE '(' push if_control_expression ')' statement pop
    11121123                { $$ = 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 ) ); }
    11131126        | DO statement WHILE '(' comma_expression ')' ';'
    11141127                { $$ = 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 ) ); }
    11151130        | FOR '(' push for_control_expression ')' statement pop
    11161131                { $$ = new StatementNode( build_for( $4, $6 ) ); }
     
    11181133
    11191134for_control_expression:
    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 ); }
     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
     1193inclexcl:
     1194        '~'
     1195                { $$ = OperKinds::LThan; }
     1196        | Erange
     1197                { $$ = OperKinds::LEThan; }
    11241198        ;
    11251199
  • src/ResolvExpr/CurrentObject.cc

    r7a7ab42 r9aa9126  
    139139                ArrayIterator( ArrayType * at ) : array( at ) {
    140140                        PRINT( std::cerr << "Creating array iterator: " << at << std::endl; )
    141                         base = at->get_base();
     141                        base = at->base;
    142142                        memberIter = createMemberIterator( base );
    143                         if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=" );
    144                         setSize( at->get_dimension() );
     143                        if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=: " );
     144                        setSize( at->dimension );
    145145                }
    146146
     
    150150
    151151        private:
    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                                 }
     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;
    169156                        } else {
    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
     157                                SemanticError( expr->location, toString("Array designator must be a constant expression: ", expr) );
    171158                        }
    172159                }
  • src/SymTab/Validate.cc

    r7a7ab42 r9aa9126  
    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        }
  • src/SynTree/AggregateDecl.cc

    r7a7ab42 r9aa9126  
    8686std::string TraitDecl::typeString() const { return "trait"; }
    8787
    88 namespace {
    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 
    10388bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) {
    10489        if ( enumValues.empty() ) {
     
    10893                        if ( field->init ) {
    10994                                SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init );
    110                                 currentValue = getConstValue( init->value );
     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;
    11198                        }
    11299                        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

    r7a7ab42 r9aa9126  
    2828#include <string>                           // for char_traits, operator<<
    2929
     30#include "CompilationState.h"
    3031#include "../config.h"                      // for CFA_LIBDIR
    3132#include "CodeGen/FixMain.h"                // for FixMain
     
    7273DeclarationNode * parseTree = nullptr;                                  // program parse tree
    7374
    74 extern int yydebug;                                                                             // set for -g flag (Grammar)
    75 bool
    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 
    10075std::string PreludeDirector = "";
    10176
     
    303278
    304279                // fix ObjectDecl - replaces ConstructorInit nodes
    305                 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
     280                PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );
    306281                if ( ctorinitp ) {
    307282                        dump ( translationUnit );
  • tests/.expect/attributes.x64.txt

    r7a7ab42 r9aa9126  
    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 [5]));
    319     ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10]));
     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)]));
    320320    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ()));
    321321    struct __attribute__ ((unused)) __anonymous3 {
  • tests/.expect/attributes.x86.txt

    r7a7ab42 r9aa9126  
    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 [5]));
    319     ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10]));
     318    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [((unsigned int )5)]));
     319    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[((unsigned int )10)]));
    320320    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ()));
    321321    struct __attribute__ ((unused)) __anonymous3 {
  • tests/function-operator.c

    r7a7ab42 r9aa9126  
    1010// Created On       : Fri Aug 25 15:21:11 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  7 12:42:26 2017
    13 // Update Count     : 6
     12// Last Modified On : Thu Aug  2 09:27:53 2018
     13// Update Count     : 8
    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);
    170173}
    171174
  • tests/sum.c

    r7a7ab42 r9aa9126  
    1111// Created On       : Wed May 27 17:56:53 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun Jun  3 19:23:41 2018
    14 // Update Count     : 278
     13// Last Modified On : Thu Aug  2 08:03:09 2018
     14// Update Count     : 279
    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 );
    117118} // main
    118119
  • tests/tuple/tupleVariadic.c

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