Changes in / [7a7ab42:9aa9126]
- Files:
-
- 7 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r7a7ab42 r9aa9126 28 28 29 29 # src executables, for lib and bin 30 src/driver/ cc130 src/driver/as 31 31 src/driver/cfa 32 32 src/driver/cfa-cpp 33 src/driver/cc1 33 34 34 35 src/prelude/bootloader.c -
driver/Makefile.am
r7a7ab42 r9aa9126 11 11 ## Created On : Sun May 31 08:49:31 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Apr 30 17:44:17201814 ## Update Count : 1 113 ## Last Modified On : Thu Aug 2 12:18:25 2018 14 ## Update Count : 14 15 15 ############################################################################### 16 16 … … 35 35 # put into lib for now 36 36 cc1libdir = ${CFA_LIBDIR} 37 cc1lib_PROGRAMS = cc1 37 cc1lib_PROGRAMS = as cc1 38 as_SOURCES = as.cc 38 39 cc1_SOURCES = cc1.cc 39 40 40 # cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT)41 # cp $(<) $(@)42 43 41 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} -
driver/Makefile.in
r7a7ab42 r9aa9126 93 93 host_triplet = @host@ 94 94 noinst_PROGRAMS = cfa$(EXEEXT) 95 cc1lib_PROGRAMS = cc1$(EXEEXT)95 cc1lib_PROGRAMS = as$(EXEEXT) cc1$(EXEEXT) 96 96 subdir = driver 97 97 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 107 107 am__installdirs = "$(DESTDIR)$(cc1libdir)" 108 108 PROGRAMS = $(cc1lib_PROGRAMS) $(noinst_PROGRAMS) 109 am_as_OBJECTS = as.$(OBJEXT) 110 as_OBJECTS = $(am_as_OBJECTS) 111 as_LDADD = $(LDADD) 109 112 am_cc1_OBJECTS = cc1.$(OBJEXT) 110 113 cc1_OBJECTS = $(am_cc1_OBJECTS) … … 142 145 am__v_CXXLD_0 = @echo " CXXLD " $@; 143 146 am__v_CXXLD_1 = 144 SOURCES = $( cc1_SOURCES) $(cfa_SOURCES)145 DIST_SOURCES = $( cc1_SOURCES) $(cfa_SOURCES)147 SOURCES = $(as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES) 148 DIST_SOURCES = $(as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES) 146 149 am__can_run_installinfo = \ 147 150 case $$AM_UPDATE_INFO_DIR in \ … … 302 305 # put into lib for now 303 306 cc1libdir = ${CFA_LIBDIR} 307 as_SOURCES = as.cc 304 308 cc1_SOURCES = cc1.cc 305 306 # cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT)307 # cp $(<) $(@)308 309 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} 309 310 all: all-am … … 386 387 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) 387 388 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 388 393 cc1$(EXEEXT): $(cc1_OBJECTS) $(cc1_DEPENDENCIES) $(EXTRA_cc1_DEPENDENCIES) 389 394 @rm -f cc1$(EXEEXT) … … 400 405 -rm -f *.tab.c 401 406 407 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/as.Po@am__quote@ 402 408 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc1.Po@am__quote@ 403 409 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfa.Po@am__quote@ -
driver/cfa.cc
r7a7ab42 r9aa9126 402 402 args[nargs] = "--undefined=__cfaabi_appready_startup"; 403 403 nargs += 1; 404 args[nargs] = "-Xlinker"; 405 nargs += 1; 406 args[nargs] = "--undefined=__cfaabi_dbg_record"; 407 nargs += 1; 404 408 405 409 // include the cfa library in case it's needed -
libcfa/prelude/builtins.c
r7a7ab42 r9aa9126 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 8 12:47:59201813 // Update Count : 1912 // Last Modified On : Sun Aug 5 21:40:38 2018 13 // Update Count : 20 14 14 // 15 15 … … 22 22 23 23 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 24 void abort 24 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 25 25 26 26 // increment/decrement unification -
libcfa/src/bits/locks.hfa
r7a7ab42 r9aa9126 64 64 extern void disable_interrupts(); 65 65 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 66 72 } 67 73 … … 71 77 this.lock = 0; 72 78 } 73 74 75 #ifdef __CFA_DEBUG__76 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);77 #else78 #define __cfaabi_dbg_record(x, y)79 #endif80 79 81 80 // Lock the spinlock, return false if already acquired -
libcfa/src/concurrency/kernel.cfa
r7a7ab42 r9aa9126 833 833 // Debug 834 834 __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 } 838 840 } 839 841 ) -
libcfa/src/startup.cfa
r7a7ab42 r9aa9126 40 40 41 41 struct __spinlock_t; 42 void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {} 42 extern "C" { 43 void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {} 44 } 43 45 44 46 // Local Variables: // -
src/CodeGen/GenType.cc
r7a7ab42 r9aa9126 27 27 namespace CodeGen { 28 28 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 ); 32 31 33 32 void previsit( BaseSyntaxNode * ); … … 58 57 void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic ); 59 58 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? 64 62 }; 65 63 … … 74 72 75 73 type->accept( gt ); 76 return os.str() + gt.pass. get_typeString();74 return os.str() + gt.pass.typeString; 77 75 } 78 76 -
src/Common/SemanticError.h
r7a7ab42 r9aa9126 58 58 {"aggregate-forward-decl" , "forward declaration of nested aggregate: %s" , Severity::Warn}, 59 59 {"superfluous-decl" , "declaration does not allocate storage: %s" , Severity::Warn}, 60 {"gcc-attributes" , "invalid attribute: %s" , Severity::Warn}, 60 61 }; 61 62 … … 66 67 AggrForwardDecl, 67 68 SuperfluousDecl, 69 GccAttributes, 68 70 NUMBER_OF_WARNINGS, // This MUST be the last warning 69 71 }; -
src/Common/module.mk
r7a7ab42 r9aa9126 19 19 Common/DebugMalloc.cc \ 20 20 Common/Assert.cc \ 21 Common/Heap.cc 21 Common/Heap.cc \ 22 Common/Eval.cc -
src/Common/utility.h
r7a7ab42 r9aa9126 31 31 #include "Common/Indenter.h" 32 32 33 class Expression; 34 33 35 template< typename T > 34 36 static inline T * maybeClone( const T *orig ) { … … 456 458 } // ilog2 457 459 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); 458 463 459 464 // Local Variables: // -
src/InitTweak/FixGlobalInit.cc
r7a7ab42 r9aa9126 37 37 class GlobalFixer : public WithShortCircuiting { 38 38 public: 39 GlobalFixer( const std::string & name,bool inLibrary );39 GlobalFixer( bool inLibrary ); 40 40 41 41 void previsit( ObjectDecl *objDecl ); … … 52 52 }; 53 53 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 ); 56 56 acceptAll( translationUnit, visitor ); 57 57 GlobalFixer & fixer = visitor.pass; … … 70 70 } 71 71 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" ) { 83 73 std::list< Expression * > ctorParameters; 84 74 std::list< Expression * > dtorParameters; … … 90 80 // for library code are run before constructors and destructors for user code, 91 81 // 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 ) ) ); 94 86 } 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() ); 96 88 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() ); 98 90 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 99 91 } … … 110 102 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 111 103 // 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 ); 113 105 114 Statement * dtor = ctorInit-> get_dtor();106 Statement * dtor = ctorInit->dtor; 115 107 if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) { 116 108 // don't need to call intrinsic dtor, because it does nothing, but 117 109 // non-intrinsic dtors must be called 118 110 destroyStatements.push_front( dtor ); 119 ctorInit-> set_dtor( NULL );111 ctorInit->dtor = nullptr; 120 112 } // if 121 if ( Statement * ctor = ctorInit-> get_ctor()) {113 if ( Statement * ctor = ctorInit->ctor ) { 122 114 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; 128 120 } else { 129 121 // no constructor and no initializer, which is okay 130 objDecl-> set_init( NULL );122 objDecl->init = nullptr; 131 123 } // if 132 124 delete ctorInit; -
src/InitTweak/FixGlobalInit.h
r7a7ab42 r9aa9126 22 22 23 23 namespace 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 ); 32 28 } // namespace 33 29 -
src/InitTweak/FixInit.cc
r7a7ab42 r9aa9126 238 238 } // namespace 239 239 240 void fix( std::list< Declaration * > & translationUnit, const std::string & filename,bool inLibrary ) {240 void fix( std::list< Declaration * > & translationUnit, bool inLibrary ) { 241 241 PassVisitor<SelfAssignChecker> checker; 242 242 acceptAll( translationUnit, checker ); 243 243 244 244 // fixes ConstructorInit for global variables. should happen before fixInitializers. 245 InitTweak::fixGlobalInit( translationUnit, filename,inLibrary );245 InitTweak::fixGlobalInit( translationUnit, inLibrary ); 246 246 247 247 UnqCount unqCount; -
src/InitTweak/FixInit.h
r7a7ab42 r9aa9126 24 24 /// replace constructor initializers with expression statements 25 25 /// 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 ); 27 27 } // namespace 28 28 -
src/InitTweak/InitTweak.cc
r7a7ab42 r9aa9126 408 408 return allofCtorDtor( stmt, []( Expression * callExpr ){ 409 409 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 410 FunctionType *funcType = GenPoly::getFunctionType( appExpr-> get_function()->get_result());410 FunctionType *funcType = GenPoly::getFunctionType( appExpr->function->result ); 411 411 assert( funcType ); 412 412 return funcType->get_parameters().size() == 1; -
src/Makefile.am
r7a7ab42 r9aa9126 19 19 20 20 SRC = main.cc \ 21 MakeLibCfa.cc 21 MakeLibCfa.cc \ 22 CompilationState.cc 22 23 23 24 MAINTAINERCLEANFILES = … … 37 38 include SynTree/module.mk 38 39 include Tuples/module.mk 40 include Validate/module.mk 39 41 include Virtual/module.mk 40 42 -
src/Makefile.in
r7a7ab42 r9aa9126 23 23 #SRC += ArgTweak/Rewriter.cc \ 24 24 # ArgTweak/Mutate.cc 25 26 ######################### -*- Mode: Makefile-Gmake -*- ######################## 27 ############################################################################### 25 28 26 29 ######################### -*- Mode: Makefile-Gmake -*- ######################## … … 150 153 am__dirstamp = $(am__leading_dot)dirstamp 151 154 am__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) \ 160 164 ControlStruct/LabelFixer.$(OBJEXT) \ 161 165 ControlStruct/MLEMutator.$(OBJEXT) \ … … 216 220 Tuples/TupleAssignment.$(OBJEXT) \ 217 221 Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \ 222 Validate/HandleAttributes.$(OBJEXT) \ 218 223 Virtual/ExpandCasts.$(OBJEXT) 219 224 am____driver_cfa_cpp_OBJECTS = $(am__objects_1) … … 308 313 $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk \ 309 314 $(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 313 319 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 314 320 ACLOCAL = @ACLOCAL@ … … 440 446 # create object files in directory with source files 441 447 AUTOMAKE_OPTIONS = subdir-objects 442 SRC = main.cc MakeLibCfa.cc Co deGen/Generate.cc \448 SRC = main.cc MakeLibCfa.cc CompilationState.cc CodeGen/Generate.cc \ 443 449 CodeGen/CodeGenerator.cc CodeGen/GenType.cc \ 444 450 CodeGen/FixNames.cc CodeGen/FixMain.cc \ … … 447 453 Concurrency/Waitfor.cc Common/SemanticError.cc \ 448 454 Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \ 449 Common/Heap.cc Co ntrolStruct/LabelGenerator.cc \455 Common/Heap.cc Common/Eval.cc ControlStruct/LabelGenerator.cc \ 450 456 ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \ 451 457 ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \ … … 489 495 SynTree/Attribute.cc SynTree/DeclReplacer.cc \ 490 496 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 491 Tuples/Explode.cc Virtual/ExpandCasts.cc 497 Tuples/Explode.cc Validate/HandleAttributes.cc \ 498 Virtual/ExpandCasts.cc 492 499 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 493 500 ${cfa_cpplib_PROGRAMS}} … … 508 515 .SUFFIXES: 509 516 .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)/V irtual/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) 511 518 @for dep in $?; do \ 512 519 case '$(am__configure_deps)' in \ … … 528 535 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 529 536 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)/V irtual/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): 531 538 532 539 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) … … 633 640 Common/$(DEPDIR)/$(am__dirstamp) 634 641 Common/Heap.$(OBJEXT): Common/$(am__dirstamp) \ 642 Common/$(DEPDIR)/$(am__dirstamp) 643 Common/Eval.$(OBJEXT): Common/$(am__dirstamp) \ 635 644 Common/$(DEPDIR)/$(am__dirstamp) 636 645 ControlStruct/$(am__dirstamp): … … 864 873 Tuples/Explode.$(OBJEXT): Tuples/$(am__dirstamp) \ 865 874 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) 866 883 Virtual/$(am__dirstamp): 867 884 @$(MKDIR_P) Virtual … … 894 911 -rm -f SynTree/*.$(OBJEXT) 895 912 -rm -f Tuples/*.$(OBJEXT) 913 -rm -f Validate/*.$(OBJEXT) 896 914 -rm -f Virtual/*.$(OBJEXT) 897 915 … … 899 917 -rm -f *.tab.c 900 918 919 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CompilationState.Po@am__quote@ 901 920 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MakeLibCfa.Po@am__quote@ 902 921 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ … … 911 930 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Assert.Po@am__quote@ 912 931 @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@ 913 933 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Heap.Po@am__quote@ 914 934 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/SemanticError.Po@am__quote@ … … 1005 1025 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/TupleAssignment.Po@am__quote@ 1006 1026 @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@ 1007 1028 @AMDEP_TRUE@@am__include@ @am__quote@Virtual/$(DEPDIR)/ExpandCasts.Po@am__quote@ 1008 1029 … … 1171 1192 -rm -f Tuples/$(DEPDIR)/$(am__dirstamp) 1172 1193 -rm -f Tuples/$(am__dirstamp) 1194 -rm -f Validate/$(DEPDIR)/$(am__dirstamp) 1195 -rm -f Validate/$(am__dirstamp) 1173 1196 -rm -f Virtual/$(DEPDIR)/$(am__dirstamp) 1174 1197 -rm -f Virtual/$(am__dirstamp) … … 1187 1210 1188 1211 distclean: 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) V irtual/$(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) 1190 1213 -rm -f Makefile 1191 1214 distclean-am: clean-am distclean-compile distclean-generic \ … … 1233 1256 1234 1257 maintainer-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) V irtual/$(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) 1236 1259 -rm -f Makefile 1237 1260 maintainer-clean-am: distclean-am maintainer-clean-generic -
src/Parser/ParseNode.h
r7a7ab42 r9aa9126 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 20 14:56:30 201813 // Update Count : 85 012 // Last Modified On : Sat Aug 4 09:39:40 2018 13 // Update Count : 853 14 14 // 15 15 … … 132 132 void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 133 133 134 Expression *get_expr() const { return expr.get(); } 134 135 template<typename T> 135 136 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); } … … 390 391 Statement * build_expr( ExpressionNode * ctl ); 391 392 392 struct IfCt l {393 IfCt l( DeclarationNode * decl, ExpressionNode * condition ) :393 struct IfCtrl { 394 IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) : 394 395 init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {} 395 396 … … 398 399 }; 399 400 400 struct ForCt l {401 ForCt l( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :401 struct ForCtrl { 402 ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) : 402 403 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {} 403 ForCt l( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :404 ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) : 404 405 init( new StatementNode( decl ) ), condition( condition ), change( change ) {} 405 406 … … 409 410 }; 410 411 411 Expression * build_if_control( IfCt l * ctl, std::list< Statement * > & init );412 Statement * build_if( IfCt l * ctl, StatementNode * then_stmt, StatementNode * else_stmt );412 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init ); 413 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 413 414 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ); 414 415 Statement * build_case( ExpressionNode * ctl ); 415 416 Statement * build_default(); 416 Statement * build_while( IfCt l * ctl, StatementNode * stmt );417 Statement * build_while( IfCtrl * ctl, StatementNode * stmt ); 417 418 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt ); 418 Statement * build_for( ForCt l * forctl, StatementNode * stmt );419 Statement * build_for( ForCtrl * forctl, StatementNode * stmt ); 419 420 Statement * build_branch( BranchStmt::Type kind ); 420 421 Statement * build_branch( std::string * identifier, BranchStmt::Type kind ); -
src/Parser/StatementNode.cc
r7a7ab42 r9aa9126 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 5 08:58:34201813 // Update Count : 36 212 // Last Modified On : Sat Aug 4 09:39:25 2018 13 // Update Count : 363 14 14 // 15 15 … … 78 78 } // build_expr 79 79 80 Expression * build_if_control( IfCt l * ctl, std::list< Statement * > & init ) {80 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init ) { 81 81 if ( ctl->init != 0 ) { 82 82 buildMoveList( ctl->init, init ); … … 100 100 } // build_if_control 101 101 102 Statement * build_if( IfCt l * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {102 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) { 103 103 Statement * thenb, * elseb = nullptr; 104 104 std::list< Statement * > branches; … … 145 145 } // build_default 146 146 147 Statement * build_while( IfCt l * ctl, StatementNode * stmt ) {147 Statement * build_while( IfCtrl * ctl, StatementNode * stmt ) { 148 148 std::list< Statement * > branches; 149 149 buildMoveList< Statement, StatementNode >( stmt, branches ); … … 164 164 } // build_do_while 165 165 166 Statement * build_for( ForCt l * forctl, StatementNode * stmt ) {166 Statement * build_for( ForCtrl * forctl, StatementNode * stmt ) { 167 167 std::list< Statement * > branches; 168 168 buildMoveList< Statement, StatementNode >( stmt, branches ); -
src/Parser/lex.ll
r7a7ab42 r9aa9126 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Jun 20 09:08:28201813 * Update Count : 68 212 * Last Modified On : Wed Aug 8 17:23:17 2018 13 * Update Count : 685 14 14 */ 15 15 … … 410 410 ">>=" { NAMEDOP_RETURN(RSassign); } 411 411 412 "~=" { NAMEDOP_RETURN(Erange); } // CFA 412 413 "@=" { NAMEDOP_RETURN(ATassign); } // CFA 413 414 -
src/Parser/parser.yy
r7a7ab42 r9aa9126 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 25 15:54:35201813 // Update Count : 3 84112 // Last Modified On : Wed Aug 8 17:50:07 2018 13 // Update Count : 3998 14 14 // 15 15 … … 186 186 } // fieldDecl 187 187 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 188 196 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 189 197 … … 217 225 WaitForStmt * wfs; 218 226 Expression * constant; 219 IfCtl * ifctl; 220 ForCtl * fctl; 227 IfCtrl * ifctl; 228 ForCtrl * fctl; 229 enum OperKinds compop; 221 230 LabelNode * label; 222 231 InitializerNode * in; … … 281 290 %token ANDassign ERassign ORassign // &= ^= |= 282 291 292 %token Erange // ~= 283 293 %token ATassign // @= 284 294 … … 303 313 %type<ifctl> if_control_expression 304 314 %type<fctl> for_control_expression 315 %type<compop> inclexcl 305 316 %type<en> subrange 306 317 %type<decl> asm_name_opt … … 1049 1060 if_control_expression: 1050 1061 comma_expression 1051 { $$ = new IfCt l( nullptr, $1 ); }1062 { $$ = new IfCtrl( nullptr, $1 ); } 1052 1063 | c_declaration // no semi-colon 1053 { $$ = new IfCt l( $1, nullptr ); }1064 { $$ = new IfCtrl( $1, nullptr ); } 1054 1065 | cfa_declaration // no semi-colon 1055 { $$ = new IfCt l( $1, nullptr ); }1066 { $$ = new IfCtrl( $1, nullptr ); } 1056 1067 | declaration comma_expression // semi-colon separated 1057 { $$ = new IfCt l( $1, $2 ); }1068 { $$ = new IfCtrl( $1, $2 ); } 1058 1069 ; 1059 1070 … … 1111 1122 WHILE '(' push if_control_expression ')' statement pop 1112 1123 { $$ = 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 ) ); } 1113 1126 | DO statement WHILE '(' comma_expression ')' ';' 1114 1127 { $$ = 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 ) ); } 1115 1130 | FOR '(' push for_control_expression ')' statement pop 1116 1131 { $$ = new StatementNode( build_for( $4, $6 ) ); } … … 1118 1133 1119 1134 for_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 1193 inclexcl: 1194 '~' 1195 { $$ = OperKinds::LThan; } 1196 | Erange 1197 { $$ = OperKinds::LEThan; } 1124 1198 ; 1125 1199 -
src/ResolvExpr/CurrentObject.cc
r7a7ab42 r9aa9126 139 139 ArrayIterator( ArrayType * at ) : array( at ) { 140 140 PRINT( std::cerr << "Creating array iterator: " << at << std::endl; ) 141 base = at-> get_base();141 base = at->base; 142 142 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 ); 145 145 } 146 146 … … 150 150 151 151 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; 169 156 } 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 this157 SemanticError( expr->location, toString("Array designator must be a constant expression: ", expr) ); 171 158 } 172 159 } -
src/SymTab/Validate.cc
r7a7ab42 r9aa9126 61 61 #include "Parser/LinkageSpec.h" // for C 62 62 #include "ResolvExpr/typeops.h" // for typesCompatible 63 #include "ResolvExpr/Resolver.h" // for findSingleExpression 63 64 #include "SymTab/Autogen.h" // for SizeType 64 65 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 72 73 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 73 74 #include "SynTree/Visitor.h" // for Visitor 75 #include "Validate/HandleAttributes.h" // for handleAttributes 74 76 75 77 class CompoundStmt; … … 247 249 }; 248 250 249 struct ArrayLength {251 struct ArrayLength : public WithIndexer { 250 252 /// for array types without an explicit length, compute the length and store it so that it 251 253 /// is known to the rest of the phases. For example, … … 258 260 259 261 void previsit( ObjectDecl * objDecl ); 262 void previsit( ArrayType * arrayType ); 260 263 }; 261 264 … … 312 315 acceptAll( translationUnit, finder ); // xxx - remove this pass soon 313 316 mutateAll( translationUnit, labelAddrFixer ); 317 Validate::handleAttributes( translationUnit ); 314 318 } 315 319 … … 734 738 forwardEnums.erase( fwds ); 735 739 } // 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 } 736 749 } // if 737 750 } … … 1232 1245 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1233 1246 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1234 if ( at-> get_dimension()) return;1247 if ( at->dimension ) return; 1235 1248 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 ); 1238 1263 } 1239 1264 } -
src/SynTree/AggregateDecl.cc
r7a7ab42 r9aa9126 86 86 std::string TraitDecl::typeString() const { return "trait"; } 87 87 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 103 88 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { 104 89 if ( enumValues.empty() ) { … … 108 93 if ( field->init ) { 109 94 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; 111 98 } 112 99 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 28 28 #include <string> // for char_traits, operator<< 29 29 30 #include "CompilationState.h" 30 31 #include "../config.h" // for CFA_LIBDIR 31 32 #include "CodeGen/FixMain.h" // for FixMain … … 72 73 DeclarationNode * parseTree = nullptr; // program parse tree 73 74 74 extern int yydebug; // set for -g flag (Grammar)75 bool76 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 AlternativeFinder91 symtabp = false,92 treep = false,93 tuplep = false,94 validp = false,95 errorp = false,96 codegenp = false,97 prettycodegenp = false,98 linemarks = false;99 100 75 std::string PreludeDirector = ""; 101 76 … … 303 278 304 279 // fix ObjectDecl - replaces ConstructorInit nodes 305 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep) );280 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) ); 306 281 if ( ctorinitp ) { 307 282 dump ( translationUnit ); -
tests/.expect/attributes.x64.txt
r7a7ab42 r9aa9126 316 316 ((void)sizeof(__attribute__ ((unused,unused)) signed int )); 317 317 ((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)])); 320 320 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 321 321 struct __attribute__ ((unused)) __anonymous3 { -
tests/.expect/attributes.x86.txt
r7a7ab42 r9aa9126 316 316 ((void)sizeof(__attribute__ ((unused,unused)) signed int )); 317 317 ((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)])); 320 320 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 321 321 struct __attribute__ ((unused)) __anonymous3 { -
tests/function-operator.c
r7a7ab42 r9aa9126 10 10 // Created On : Fri Aug 25 15:21:11 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 7 12:42:26 201713 // Update Count : 612 // Last Modified On : Thu Aug 2 09:27:53 2018 13 // Update Count : 8 14 14 // 15 15 … … 92 92 void ?{}(ostream_iterator & iter, ofstream * out) { 93 93 iter.out = new(out); 94 94 } 95 95 // no destructor, memory leak. This is necessary for this to work at the moment, since 96 96 // *? requires its parameter by value and returns a reference. … … 168 168 transform(begin(x), end(x), begin(x), ×2); 169 169 copy(begin(x), end(x), out_iter); 170 171 // REMOVE WHEN ?* PROBLEM FIXED. 172 delete(out_iter.out); 170 173 } 171 174 -
tests/sum.c
r7a7ab42 r9aa9126 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Sun Jun 3 19:23:41201814 // Update Count : 27 813 // Last Modified On : Thu Aug 2 08:03:09 2018 14 // Update Count : 279 15 15 // 16 16 … … 115 115 sout | "sum from" | low | "to" | High | "is" 116 116 | sum( size, gs.x ) | ", check" | (int)s | endl; // add field array in generic type 117 delete( gs.x ); 117 118 } // main 118 119 -
tests/tuple/tupleVariadic.c
r7a7ab42 r9aa9126 9 9 // Author : Rob Schluntz 10 10 // Created On : Fri Dec 16 10:25:35 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Dec 21 14:42:48 201613 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 2 09:24:04 2018 13 // Update Count : 6 14 14 // 15 16 #include <stdlib> 15 17 16 18 void func(void) { … … 28 30 printf("called process(double) %g\n", x); 29 31 } 30 31 forall( dtype T, ttype Params | sized(T) | { void ?{}(T &, Params); } )32 T * new(Params p);33 32 34 33 struct array { … … 66 65 a.data[2] = a2; 67 66 printf("called ?{} with a: %d %d %d\n", a0, a1, a2); 67 } 68 69 void ^?{}(array & a) { 70 free(a.data); 68 71 } 69 72 … … 126 129 bar(x); 127 130 } 131 132 delete(ptr); 133 delete(x4); 134 delete(x3); 135 delete(x2); 136 delete(x1); 137 delete(x0); 128 138 } 129 139 … … 131 141 // tab-width: 4 // 132 142 // End: // 133
Note: See TracChangeset
for help on using the changeset viewer.