Changes in / [9aa9126:7a7ab42]
- Files:
-
- 7 deleted
- 32 edited
-
.gitignore (modified) (1 diff)
-
driver/Makefile.am (modified) (2 diffs)
-
driver/Makefile.in (modified) (6 diffs)
-
driver/cfa.cc (modified) (1 diff)
-
libcfa/prelude/builtins.c (modified) (2 diffs)
-
libcfa/src/bits/locks.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/kernel.cfa (modified) (1 diff)
-
libcfa/src/startup.cfa (modified) (1 diff)
-
src/CodeGen/GenType.cc (modified) (3 diffs)
-
src/Common/Eval.cc (deleted)
-
src/Common/SemanticError.h (modified) (2 diffs)
-
src/Common/module.mk (modified) (1 diff)
-
src/Common/utility.h (modified) (2 diffs)
-
src/CompilationState.cc (deleted)
-
src/CompilationState.h (deleted)
-
src/InitTweak/FixGlobalInit.cc (modified) (5 diffs)
-
src/InitTweak/FixGlobalInit.h (modified) (1 diff)
-
src/InitTweak/FixInit.cc (modified) (1 diff)
-
src/InitTweak/FixInit.h (modified) (1 diff)
-
src/InitTweak/InitTweak.cc (modified) (1 diff)
-
src/Makefile.am (modified) (2 diffs)
-
src/Makefile.in (modified) (18 diffs)
-
src/Parser/ParseNode.h (modified) (5 diffs)
-
src/Parser/StatementNode.cc (modified) (5 diffs)
-
src/Parser/lex.ll (modified) (2 diffs)
-
src/Parser/parser.yy (modified) (8 diffs)
-
src/ResolvExpr/CurrentObject.cc (modified) (2 diffs)
-
src/SymTab/Validate.cc (modified) (7 diffs)
-
src/SynTree/AggregateDecl.cc (modified) (2 diffs)
-
src/Validate/HandleAttributes.cc (deleted)
-
src/Validate/HandleAttributes.h (deleted)
-
src/Validate/module.mk (deleted)
-
src/driver/as.cc (deleted)
-
src/main.cc (modified) (3 diffs)
-
tests/.expect/attributes.x64.txt (modified) (1 diff)
-
tests/.expect/attributes.x86.txt (modified) (1 diff)
-
tests/function-operator.c (modified) (3 diffs)
-
tests/sum.c (modified) (2 diffs)
-
tests/tuple/tupleVariadic.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r9aa9126 r7a7ab42 28 28 29 29 # src executables, for lib and bin 30 src/driver/ as30 src/driver/cc1 31 31 src/driver/cfa 32 32 src/driver/cfa-cpp 33 src/driver/cc134 33 35 34 src/prelude/bootloader.c -
driver/Makefile.am
r9aa9126 r7a7ab42 11 11 ## Created On : Sun May 31 08:49:31 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Thu Aug 2 12:18:25201814 ## Update Count : 1 413 ## Last Modified On : Mon Apr 30 17:44:17 2018 14 ## Update Count : 11 15 15 ############################################################################### 16 16 … … 35 35 # put into lib for now 36 36 cc1libdir = ${CFA_LIBDIR} 37 cc1lib_PROGRAMS = as cc1 38 as_SOURCES = as.cc 37 cc1lib_PROGRAMS = cc1 39 38 cc1_SOURCES = cc1.cc 40 39 40 # cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT) 41 # cp $(<) $(@) 42 41 43 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} -
driver/Makefile.in
r9aa9126 r7a7ab42 93 93 host_triplet = @host@ 94 94 noinst_PROGRAMS = cfa$(EXEEXT) 95 cc1lib_PROGRAMS = as$(EXEEXT)cc1$(EXEEXT)95 cc1lib_PROGRAMS = 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)112 109 am_cc1_OBJECTS = cc1.$(OBJEXT) 113 110 cc1_OBJECTS = $(am_cc1_OBJECTS) … … 145 142 am__v_CXXLD_0 = @echo " CXXLD " $@; 146 143 am__v_CXXLD_1 = 147 SOURCES = $( as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES)148 DIST_SOURCES = $( as_SOURCES) $(cc1_SOURCES) $(cfa_SOURCES)144 SOURCES = $(cc1_SOURCES) $(cfa_SOURCES) 145 DIST_SOURCES = $(cc1_SOURCES) $(cfa_SOURCES) 149 146 am__can_run_installinfo = \ 150 147 case $$AM_UPDATE_INFO_DIR in \ … … 305 302 # put into lib for now 306 303 cc1libdir = ${CFA_LIBDIR} 307 as_SOURCES = as.cc308 304 cc1_SOURCES = cc1.cc 305 306 # cfa-cpp$(EXEEXT): $(top_builddir)/driver/cfa-cpp$(EXEEXT) 307 # cp $(<) $(@) 309 308 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} 310 309 all: all-am … … 387 386 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) 388 387 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 393 388 cc1$(EXEEXT): $(cc1_OBJECTS) $(cc1_DEPENDENCIES) $(EXTRA_cc1_DEPENDENCIES) 394 389 @rm -f cc1$(EXEEXT) … … 405 400 -rm -f *.tab.c 406 401 407 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/as.Po@am__quote@408 402 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc1.Po@am__quote@ 409 403 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfa.Po@am__quote@ -
driver/cfa.cc
r9aa9126 r7a7ab42 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;408 404 409 405 // include the cfa library in case it's needed -
libcfa/prelude/builtins.c
r9aa9126 r7a7ab42 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 5 21:40:38201813 // Update Count : 2012 // Last Modified On : Thu Feb 8 12:47:59 2018 13 // Update Count : 19 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 ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));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
r9aa9126 r7a7ab42 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 #else70 #define __cfaabi_dbg_record(x, y)71 #endif72 66 } 73 67 … … 77 71 this.lock = 0; 78 72 } 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 79 80 80 81 // Lock the spinlock, return false if already acquired -
libcfa/src/concurrency/kernel.cfa
r9aa9126 r7a7ab42 833 833 // Debug 834 834 __cfaabi_dbg_debug_do( 835 extern "C" { 836 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) { 837 this.prev_name = prev_name; 838 this.prev_thrd = kernelTLS.this_thread; 839 } 835 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) { 836 this.prev_name = prev_name; 837 this.prev_thrd = kernelTLS.this_thread; 840 838 } 841 839 ) -
libcfa/src/startup.cfa
r9aa9126 r7a7ab42 40 40 41 41 struct __spinlock_t; 42 extern "C" { 43 void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {} 44 } 42 void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {} 45 43 46 44 // Local Variables: // -
src/CodeGen/GenType.cc
r9aa9126 r7a7ab42 27 27 namespace CodeGen { 28 28 struct GenType : public WithVisitorRef<GenType>, public WithShortCircuiting { 29 std::string typeString; 30 GenType( const std::string &typeString, bool pretty, bool genC, bool lineMarks ); 29 GenType( const std::string &typeString, bool pretty = false, bool genC = false, bool lineMarks = false ); 30 std::string get_typeString() const { return typeString; } 31 void set_typeString( const std::string &newValue ) { typeString = newValue; } 31 32 32 33 void previsit( BaseSyntaxNode * ); … … 57 58 void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic ); 58 59 59 bool pretty = false; // pretty print 60 bool genC = false; // generating C code? 61 bool lineMarks = false; // lineMarks on for CodeGenerator? 60 std::string typeString; 61 bool pretty = false; // pretty print 62 bool genC = false; // generating C code? 63 bool lineMarks = false; 62 64 }; 63 65 … … 72 74 73 75 type->accept( gt ); 74 return os.str() + gt.pass. typeString;76 return os.str() + gt.pass.get_typeString(); 75 77 } 76 78 -
src/Common/SemanticError.h
r9aa9126 r7a7ab42 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},61 60 }; 62 61 … … 67 66 AggrForwardDecl, 68 67 SuperfluousDecl, 69 GccAttributes,70 68 NUMBER_OF_WARNINGS, // This MUST be the last warning 71 69 }; -
src/Common/module.mk
r9aa9126 r7a7ab42 19 19 Common/DebugMalloc.cc \ 20 20 Common/Assert.cc \ 21 Common/Heap.cc \ 22 Common/Eval.cc 21 Common/Heap.cc -
src/Common/utility.h
r9aa9126 r7a7ab42 31 31 #include "Common/Indenter.h" 32 32 33 class Expression;34 35 33 template< typename T > 36 34 static inline T * maybeClone( const T *orig ) { … … 458 456 } // ilog2 459 457 460 // -----------------------------------------------------------------------------461 /// evaluates expr as a long long int. If second is false, expr could not be evaluated462 std::pair<long long int, bool> eval(Expression * expr);463 458 464 459 // Local Variables: // -
src/InitTweak/FixGlobalInit.cc
r9aa9126 r7a7ab42 37 37 class GlobalFixer : public WithShortCircuiting { 38 38 public: 39 GlobalFixer( bool inLibrary );39 GlobalFixer( const std::string & name, bool inLibrary ); 40 40 41 41 void previsit( ObjectDecl *objDecl ); … … 52 52 }; 53 53 54 void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary ) {55 PassVisitor<GlobalFixer> visitor( inLibrary );54 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ) { 55 PassVisitor<GlobalFixer> visitor( name, inLibrary ); 56 56 acceptAll( translationUnit, visitor ); 57 57 GlobalFixer & fixer = visitor.pass; … … 70 70 } 71 71 72 GlobalFixer::GlobalFixer( bool inLibrary ) : tempNamer( "_global_init" ) { 72 std::string globalFunctionName( const std::string & name ) { 73 // get basename 74 std::string ret = name.substr( 0, name.find( '.' ) ); 75 // replace invalid characters with _ 76 static std::string invalid = "/-@"; 77 replace_if( ret.begin(), ret.end(), []( char c ) { return invalid.find(c) != std::string::npos; }, '_' ); 78 return ret; 79 } 80 81 GlobalFixer::GlobalFixer( const std::string & name, bool inLibrary ) : tempNamer( "_global_init" ) { 82 std::string fixedName = globalFunctionName( name ); 73 83 std::list< Expression * > ctorParameters; 74 84 std::list< Expression * > dtorParameters; … … 80 90 // for library code are run before constructors and destructors for user code, 81 91 // specify a priority when building the library. Priorities 0-100 are reserved by gcc. 82 // Priorities 101-200 are reserved by cfa, so use priority 200 for CFA library globals, 83 // allowing room for overriding with a higher priority. 84 ctorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) ); 85 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) ); 92 ctorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 93 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 86 94 } 87 initFunction = new FunctionDecl( "_ _global_init__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );95 initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 88 96 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 89 destroyFunction = new FunctionDecl( "_ _global_destroy__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );97 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 90 98 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 91 99 } … … 102 110 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 103 111 // a decision should have been made by the resolver, so ctor and init are not both non-NULL 104 assert( ! ctorInit-> ctor || ! ctorInit->init);112 assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() ); 105 113 106 Statement * dtor = ctorInit-> dtor;114 Statement * dtor = ctorInit->get_dtor(); 107 115 if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) { 108 116 // don't need to call intrinsic dtor, because it does nothing, but 109 117 // non-intrinsic dtors must be called 110 118 destroyStatements.push_front( dtor ); 111 ctorInit-> dtor = nullptr;119 ctorInit->set_dtor( NULL ); 112 120 } // if 113 if ( Statement * ctor = ctorInit-> ctor) {121 if ( Statement * ctor = ctorInit->get_ctor() ) { 114 122 initStatements.push_back( ctor ); 115 objDecl-> init = nullptr;116 ctorInit-> ctor = nullptr;117 } else if ( Initializer * init = ctorInit-> init) {118 objDecl-> init = init;119 ctorInit-> init = nullptr;123 objDecl->set_init( NULL ); 124 ctorInit->set_ctor( NULL ); 125 } else if ( Initializer * init = ctorInit->get_init() ) { 126 objDecl->set_init( init ); 127 ctorInit->set_init( NULL ); 120 128 } else { 121 129 // no constructor and no initializer, which is okay 122 objDecl-> init = nullptr;130 objDecl->set_init( NULL ); 123 131 } // if 124 132 delete ctorInit; -
src/InitTweak/FixGlobalInit.h
r9aa9126 r7a7ab42 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, bool inLibrary ); 24 /// Moves global initialization into an _init function that is unique to the translation unit. 25 /// Sets the priority of the initialization function depending on whether the initialization 26 /// function is for library code. 27 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ); 28 29 /// Apply transformations to a file name to get a valid C identifier which will be used as 30 /// the name of the generated initializer function. 31 std::string globalFunctionName( const std::string & name ); 28 32 } // namespace 29 33 -
src/InitTweak/FixInit.cc
r9aa9126 r7a7ab42 238 238 } // namespace 239 239 240 void fix( std::list< Declaration * > & translationUnit, bool inLibrary ) {240 void fix( std::list< Declaration * > & translationUnit, const std::string & filename, 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, inLibrary );245 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); 246 246 247 247 UnqCount unqCount; -
src/InitTweak/FixInit.h
r9aa9126 r7a7ab42 24 24 /// replace constructor initializers with expression statements 25 25 /// and unwrap basic C-style initializers 26 void fix( std::list< Declaration * > & translationUnit, bool inLibrary );26 void fix( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ); 27 27 } // namespace 28 28 -
src/InitTweak/InitTweak.cc
r9aa9126 r7a7ab42 408 408 return allofCtorDtor( stmt, []( Expression * callExpr ){ 409 409 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 410 FunctionType *funcType = GenPoly::getFunctionType( appExpr-> function->result);410 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() ); 411 411 assert( funcType ); 412 412 return funcType->get_parameters().size() == 1; -
src/Makefile.am
r9aa9126 r7a7ab42 19 19 20 20 SRC = main.cc \ 21 MakeLibCfa.cc \ 22 CompilationState.cc 21 MakeLibCfa.cc 23 22 24 23 MAINTAINERCLEANFILES = … … 38 37 include SynTree/module.mk 39 38 include Tuples/module.mk 40 include Validate/module.mk41 39 include Virtual/module.mk 42 40 -
src/Makefile.in
r9aa9126 r7a7ab42 23 23 #SRC += ArgTweak/Rewriter.cc \ 24 24 # ArgTweak/Mutate.cc 25 26 ######################### -*- Mode: Makefile-Gmake -*- ########################27 ###############################################################################28 25 29 26 ######################### -*- Mode: Makefile-Gmake -*- ######################## … … 153 150 am__dirstamp = $(am__leading_dot)dirstamp 154 151 am__objects_1 = main.$(OBJEXT) MakeLibCfa.$(OBJEXT) \ 155 CompilationState.$(OBJEXT) CodeGen/Generate.$(OBJEXT) \ 156 CodeGen/CodeGenerator.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \ 157 CodeGen/FixNames.$(OBJEXT) CodeGen/FixMain.$(OBJEXT) \ 158 CodeGen/OperatorTable.$(OBJEXT) CodeTools/DeclStats.$(OBJEXT) \ 159 CodeTools/TrackLoc.$(OBJEXT) Concurrency/Keywords.$(OBJEXT) \ 160 Concurrency/Waitfor.$(OBJEXT) Common/SemanticError.$(OBJEXT) \ 161 Common/UniqueName.$(OBJEXT) Common/DebugMalloc.$(OBJEXT) \ 162 Common/Assert.$(OBJEXT) Common/Heap.$(OBJEXT) \ 163 Common/Eval.$(OBJEXT) ControlStruct/LabelGenerator.$(OBJEXT) \ 152 CodeGen/Generate.$(OBJEXT) CodeGen/CodeGenerator.$(OBJEXT) \ 153 CodeGen/GenType.$(OBJEXT) CodeGen/FixNames.$(OBJEXT) \ 154 CodeGen/FixMain.$(OBJEXT) CodeGen/OperatorTable.$(OBJEXT) \ 155 CodeTools/DeclStats.$(OBJEXT) CodeTools/TrackLoc.$(OBJEXT) \ 156 Concurrency/Keywords.$(OBJEXT) Concurrency/Waitfor.$(OBJEXT) \ 157 Common/SemanticError.$(OBJEXT) Common/UniqueName.$(OBJEXT) \ 158 Common/DebugMalloc.$(OBJEXT) Common/Assert.$(OBJEXT) \ 159 Common/Heap.$(OBJEXT) ControlStruct/LabelGenerator.$(OBJEXT) \ 164 160 ControlStruct/LabelFixer.$(OBJEXT) \ 165 161 ControlStruct/MLEMutator.$(OBJEXT) \ … … 220 216 Tuples/TupleAssignment.$(OBJEXT) \ 221 217 Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \ 222 Validate/HandleAttributes.$(OBJEXT) \223 218 Virtual/ExpandCasts.$(OBJEXT) 224 219 am____driver_cfa_cpp_OBJECTS = $(am__objects_1) … … 313 308 $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk \ 314 309 $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk \ 315 $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk \ 316 $(srcdir)/Virtual/module.mk $(top_srcdir)/automake/depcomp \ 317 $(top_srcdir)/automake/ylwrap Parser/lex.cc Parser/parser.cc \ 318 Parser/parser.hh 310 $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk \ 311 $(top_srcdir)/automake/depcomp $(top_srcdir)/automake/ylwrap \ 312 Parser/lex.cc Parser/parser.cc Parser/parser.hh 319 313 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 320 314 ACLOCAL = @ACLOCAL@ … … 446 440 # create object files in directory with source files 447 441 AUTOMAKE_OPTIONS = subdir-objects 448 SRC = main.cc MakeLibCfa.cc Co mpilationState.cc CodeGen/Generate.cc \442 SRC = main.cc MakeLibCfa.cc CodeGen/Generate.cc \ 449 443 CodeGen/CodeGenerator.cc CodeGen/GenType.cc \ 450 444 CodeGen/FixNames.cc CodeGen/FixMain.cc \ … … 453 447 Concurrency/Waitfor.cc Common/SemanticError.cc \ 454 448 Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \ 455 Common/Heap.cc Co mmon/Eval.cc ControlStruct/LabelGenerator.cc \449 Common/Heap.cc ControlStruct/LabelGenerator.cc \ 456 450 ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \ 457 451 ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \ … … 495 489 SynTree/Attribute.cc SynTree/DeclReplacer.cc \ 496 490 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 497 Tuples/Explode.cc Validate/HandleAttributes.cc \ 498 Virtual/ExpandCasts.cc 491 Tuples/Explode.cc Virtual/ExpandCasts.cc 499 492 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 500 493 ${cfa_cpplib_PROGRAMS}} … … 515 508 .SUFFIXES: 516 509 .SUFFIXES: .cc .ll .o .obj .yy 517 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/V alidate/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps)510 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps) 518 511 @for dep in $?; do \ 519 512 case '$(am__configure_deps)' in \ … … 535 528 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 536 529 esac; 537 $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/V alidate/module.mk $(srcdir)/Virtual/module.mk $(am__empty):530 $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk $(am__empty): 538 531 539 532 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) … … 640 633 Common/$(DEPDIR)/$(am__dirstamp) 641 634 Common/Heap.$(OBJEXT): Common/$(am__dirstamp) \ 642 Common/$(DEPDIR)/$(am__dirstamp)643 Common/Eval.$(OBJEXT): Common/$(am__dirstamp) \644 635 Common/$(DEPDIR)/$(am__dirstamp) 645 636 ControlStruct/$(am__dirstamp): … … 873 864 Tuples/Explode.$(OBJEXT): Tuples/$(am__dirstamp) \ 874 865 Tuples/$(DEPDIR)/$(am__dirstamp) 875 Validate/$(am__dirstamp):876 @$(MKDIR_P) Validate877 @: > 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)883 866 Virtual/$(am__dirstamp): 884 867 @$(MKDIR_P) Virtual … … 911 894 -rm -f SynTree/*.$(OBJEXT) 912 895 -rm -f Tuples/*.$(OBJEXT) 913 -rm -f Validate/*.$(OBJEXT)914 896 -rm -f Virtual/*.$(OBJEXT) 915 897 … … 917 899 -rm -f *.tab.c 918 900 919 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CompilationState.Po@am__quote@920 901 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MakeLibCfa.Po@am__quote@ 921 902 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ … … 930 911 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Assert.Po@am__quote@ 931 912 @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@933 913 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Heap.Po@am__quote@ 934 914 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/SemanticError.Po@am__quote@ … … 1025 1005 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/TupleAssignment.Po@am__quote@ 1026 1006 @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@1028 1007 @AMDEP_TRUE@@am__include@ @am__quote@Virtual/$(DEPDIR)/ExpandCasts.Po@am__quote@ 1029 1008 … … 1192 1171 -rm -f Tuples/$(DEPDIR)/$(am__dirstamp) 1193 1172 -rm -f Tuples/$(am__dirstamp) 1194 -rm -f Validate/$(DEPDIR)/$(am__dirstamp)1195 -rm -f Validate/$(am__dirstamp)1196 1173 -rm -f Virtual/$(DEPDIR)/$(am__dirstamp) 1197 1174 -rm -f Virtual/$(am__dirstamp) … … 1210 1187 1211 1188 distclean: distclean-am 1212 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) V alidate/$(DEPDIR) Virtual/$(DEPDIR)1189 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Virtual/$(DEPDIR) 1213 1190 -rm -f Makefile 1214 1191 distclean-am: clean-am distclean-compile distclean-generic \ … … 1256 1233 1257 1234 maintainer-clean: maintainer-clean-am 1258 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) V alidate/$(DEPDIR) Virtual/$(DEPDIR)1235 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Virtual/$(DEPDIR) 1259 1236 -rm -f Makefile 1260 1237 maintainer-clean-am: distclean-am maintainer-clean-generic -
src/Parser/ParseNode.h
r9aa9126 r7a7ab42 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 4 09:39:40 201813 // Update Count : 85 312 // Last Modified On : Fri Jul 20 14:56:30 2018 13 // Update Count : 850 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(); }135 134 template<typename T> 136 135 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); } … … 391 390 Statement * build_expr( ExpressionNode * ctl ); 392 391 393 struct IfCt rl {394 IfCt rl( DeclarationNode * decl, ExpressionNode * condition ) :392 struct IfCtl { 393 IfCtl( DeclarationNode * decl, ExpressionNode * condition ) : 395 394 init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {} 396 395 … … 399 398 }; 400 399 401 struct ForCt rl {402 ForCt rl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :400 struct ForCtl { 401 ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) : 403 402 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {} 404 ForCt rl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :403 ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) : 405 404 init( new StatementNode( decl ) ), condition( condition ), change( change ) {} 406 405 … … 410 409 }; 411 410 412 Expression * build_if_control( IfCt rl * ctl, std::list< Statement * > & init );413 Statement * build_if( IfCt rl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );411 Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init ); 412 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 414 413 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ); 415 414 Statement * build_case( ExpressionNode * ctl ); 416 415 Statement * build_default(); 417 Statement * build_while( IfCt rl * ctl, StatementNode * stmt );416 Statement * build_while( IfCtl * ctl, StatementNode * stmt ); 418 417 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt ); 419 Statement * build_for( ForCt rl * forctl, StatementNode * stmt );418 Statement * build_for( ForCtl * forctl, StatementNode * stmt ); 420 419 Statement * build_branch( BranchStmt::Type kind ); 421 420 Statement * build_branch( std::string * identifier, BranchStmt::Type kind ); -
src/Parser/StatementNode.cc
r9aa9126 r7a7ab42 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 4 09:39:25201813 // Update Count : 36 312 // Last Modified On : Tue Jun 5 08:58:34 2018 13 // Update Count : 362 14 14 // 15 15 … … 78 78 } // build_expr 79 79 80 Expression * build_if_control( IfCt rl * ctl, std::list< Statement * > & init ) {80 Expression * build_if_control( IfCtl * 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 rl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {102 Statement * build_if( IfCtl * 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 rl * ctl, StatementNode * stmt ) {147 Statement * build_while( IfCtl * 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 rl * forctl, StatementNode * stmt ) {166 Statement * build_for( ForCtl * forctl, StatementNode * stmt ) { 167 167 std::list< Statement * > branches; 168 168 buildMoveList< Statement, StatementNode >( stmt, branches ); -
src/Parser/lex.ll
r9aa9126 r7a7ab42 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Aug 8 17:23:17201813 * Update Count : 68 512 * Last Modified On : Wed Jun 20 09:08:28 2018 13 * Update Count : 682 14 14 */ 15 15 … … 410 410 ">>=" { NAMEDOP_RETURN(RSassign); } 411 411 412 "~=" { NAMEDOP_RETURN(Erange); } // CFA413 412 "@=" { NAMEDOP_RETURN(ATassign); } // CFA 414 413 -
src/Parser/parser.yy
r9aa9126 r7a7ab42 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 8 17:50:07201813 // Update Count : 3 99812 // Last Modified On : Wed Jul 25 15:54:35 2018 13 // Update Count : 3841 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 } // forCtrl194 195 196 188 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 197 189 … … 225 217 WaitForStmt * wfs; 226 218 Expression * constant; 227 IfCtrl * ifctl; 228 ForCtrl * fctl; 229 enum OperKinds compop; 219 IfCtl * ifctl; 220 ForCtl * fctl; 230 221 LabelNode * label; 231 222 InitializerNode * in; … … 290 281 %token ANDassign ERassign ORassign // &= ^= |= 291 282 292 %token Erange // ~=293 283 %token ATassign // @= 294 284 … … 313 303 %type<ifctl> if_control_expression 314 304 %type<fctl> for_control_expression 315 %type<compop> inclexcl316 305 %type<en> subrange 317 306 %type<decl> asm_name_opt … … 1060 1049 if_control_expression: 1061 1050 comma_expression 1062 { $$ = new IfCt rl( nullptr, $1 ); }1051 { $$ = new IfCtl( nullptr, $1 ); } 1063 1052 | c_declaration // no semi-colon 1064 { $$ = new IfCt rl( $1, nullptr ); }1053 { $$ = new IfCtl( $1, nullptr ); } 1065 1054 | cfa_declaration // no semi-colon 1066 { $$ = new IfCt rl( $1, nullptr ); }1055 { $$ = new IfCtl( $1, nullptr ); } 1067 1056 | declaration comma_expression // semi-colon separated 1068 { $$ = new IfCt rl( $1, $2 ); }1057 { $$ = new IfCtl( $1, $2 ); } 1069 1058 ; 1070 1059 … … 1122 1111 WHILE '(' push if_control_expression ')' statement pop 1123 1112 { $$ = 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 ) ); }1126 1113 | DO statement WHILE '(' comma_expression ')' ';' 1127 1114 { $$ = 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 ) ); }1130 1115 | FOR '(' push for_control_expression ')' statement pop 1131 1116 { $$ = new StatementNode( build_for( $4, $6 ) ); } … … 1133 1118 1134 1119 for_control_expression: 1135 comma_expression_opt // CFA 1136 { 1137 if ( ! $1 ) { // => for ( ;; ) 1138 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ); 1139 } else { 1140 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $1->clone(), 1141 new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1142 } // if 1143 } 1144 | constant_expression inclexcl constant_expression // CFA 1145 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1146 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1147 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } 1148 | comma_expression_opt ';' comma_expression // CFA 1149 { 1150 if ( ! $1 ) { 1151 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr; 1152 } else if ( ! $3 ) { 1153 SemanticError( yylloc, "Missing loop range." ); $$ = nullptr; 1154 } else { 1155 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1156 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $3->clone(), 1157 new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1158 } else { 1159 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; 1160 } // if 1161 } // if 1162 } 1163 | comma_expression_opt ';' constant_expression inclexcl constant_expression // CFA 1164 { 1165 if ( ! $1 ) { 1166 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr; 1167 } else { 1168 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1169 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1170 } else { 1171 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; 1172 } // if 1173 } // if 1174 } 1175 | comma_expression_opt ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA 1176 { 1177 if ( ! $1 ) { 1178 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr; 1179 } else { 1180 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1181 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, $7 ); 1182 } else { 1183 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; 1184 } // if 1185 } // if 1186 } 1187 | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt 1188 { $$ = new ForCtrl( $1, $3, $5 ); } 1189 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1190 { $$ = new ForCtrl( $1, $2, $4 ); } 1191 ; 1192 1193 inclexcl: 1194 '~' 1195 { $$ = OperKinds::LThan; } 1196 | Erange 1197 { $$ = OperKinds::LEThan; } 1120 comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt 1121 { $$ = new ForCtl( $1, $3, $5 ); } 1122 | declaration comma_expression_opt ';' comma_expression_opt // C99 1123 { $$ = new ForCtl( $1, $2, $4 ); } 1198 1124 ; 1199 1125 -
src/ResolvExpr/CurrentObject.cc
r9aa9126 r7a7ab42 139 139 ArrayIterator( ArrayType * at ) : array( at ) { 140 140 PRINT( std::cerr << "Creating array iterator: " << at << std::endl; ) 141 base = at-> base;141 base = at->get_base(); 142 142 memberIter = createMemberIterator( base ); 143 if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @= :" );144 setSize( at-> dimension);143 if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=" ); 144 setSize( at->get_dimension() ); 145 145 } 146 146 … … 150 150 151 151 private: 152 void setSize( Expression * expr ) { // replace this logic with an eval call 153 auto res = eval(expr); 154 if (res.second) { 155 size = res.first; 152 void setSize( Expression * expr ) { 153 if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) { 154 try { 155 size = constExpr->intValue(); 156 PRINT( std::cerr << "array type with size: " << size << std::endl; ) 157 } catch ( SemanticErrorException & ) { 158 SemanticError( expr, "Constant expression of non-integral type in array dimension: " ); 159 } 160 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { 161 setSize( castExpr->get_arg() ); // xxx - need to perform the conversion specified by the cast 162 } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) { 163 if ( EnumInstType * inst = dynamic_cast< EnumInstType * > ( varExpr->result ) ) { 164 long long int value; 165 if ( inst->baseEnum->valueOf( varExpr->var, value ) ) { 166 size = value; 167 } 168 } 156 169 } else { 157 SemanticError( expr->location, toString("Array designator must be a constant expression: ", expr) );170 assertf( false, "unhandled expression in setSize: %s", toString( expr ).c_str() ); // xxx - if not a constant expression, it's not simple to determine how long the array actually is, which is necessary for initialization to be done correctly -- fix this 158 171 } 159 172 } -
src/SymTab/Validate.cc
r9aa9126 r7a7ab42 61 61 #include "Parser/LinkageSpec.h" // for C 62 62 #include "ResolvExpr/typeops.h" // for typesCompatible 63 #include "ResolvExpr/Resolver.h" // for findSingleExpression64 63 #include "SymTab/Autogen.h" // for SizeType 65 64 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 73 72 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 74 73 #include "SynTree/Visitor.h" // for Visitor 75 #include "Validate/HandleAttributes.h" // for handleAttributes76 74 77 75 class CompoundStmt; … … 249 247 }; 250 248 251 struct ArrayLength : public WithIndexer{249 struct ArrayLength { 252 250 /// for array types without an explicit length, compute the length and store it so that it 253 251 /// is known to the rest of the phases. For example, … … 260 258 261 259 void previsit( ObjectDecl * objDecl ); 262 void previsit( ArrayType * arrayType );263 260 }; 264 261 … … 315 312 acceptAll( translationUnit, finder ); // xxx - remove this pass soon 316 313 mutateAll( translationUnit, labelAddrFixer ); 317 Validate::handleAttributes( translationUnit );318 314 } 319 315 … … 738 734 forwardEnums.erase( fwds ); 739 735 } // 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 }749 736 } // if 750 737 } … … 1245 1232 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1246 1233 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1247 if ( at-> dimension) return;1234 if ( at->get_dimension() ) return; 1248 1235 if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) { 1249 at->dimension = new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ); 1250 } 1251 } 1252 } 1253 1254 void ArrayLength::previsit( ArrayType * type ) { 1255 if ( type->dimension ) { 1256 // need to resolve array dimensions early so that constructor code can correctly determine 1257 // if a type is a VLA (and hence whether its elements need to be constructed) 1258 ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer ); 1259 1260 // must re-evaluate whether a type is a VLA, now that more information is available 1261 // (e.g. the dimension may have been an enumerator, which was unknown prior to this step) 1262 type->isVarLen = ! InitTweak::isConstExpr( type->dimension ); 1236 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) ); 1237 } 1263 1238 } 1264 1239 } -
src/SynTree/AggregateDecl.cc
r9aa9126 r7a7ab42 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 88 103 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { 89 104 if ( enumValues.empty() ) { … … 93 108 if ( field->init ) { 94 109 SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init ); 95 auto result = eval( init->value ); 96 if ( ! result.second ) SemanticError( init->location, toString( "Non-constexpr in initialization of enumerator: ", field ) ); 97 currentValue = result.first; 110 currentValue = getConstValue( init->value ); 98 111 } 99 112 assertf( enumValues.count( field->name ) == 0, "Enum %s has multiple members with the name %s", name.c_str(), field->name.c_str() ); -
src/main.cc
r9aa9126 r7a7ab42 28 28 #include <string> // for char_traits, operator<< 29 29 30 #include "CompilationState.h"31 30 #include "../config.h" // for CFA_LIBDIR 32 31 #include "CodeGen/FixMain.h" // for FixMain … … 73 72 DeclarationNode * parseTree = nullptr; // program parse tree 74 73 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 75 100 std::string PreludeDirector = ""; 76 101 … … 278 303 279 304 // fix ObjectDecl - replaces ConstructorInit nodes 280 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary()) );305 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) ); 281 306 if ( ctorinitp ) { 282 307 dump ( translationUnit ); -
tests/.expect/attributes.x64.txt
r9aa9126 r7a7ab42 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 [ ((unsigned long int )5)]));319 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[ ((unsigned long int )10)]));318 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [5])); 319 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10])); 320 320 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 321 321 struct __attribute__ ((unused)) __anonymous3 { -
tests/.expect/attributes.x86.txt
r9aa9126 r7a7ab42 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 [ ((unsigned int )5)]));319 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[ ((unsigned int )10)]));318 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [5])); 319 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10])); 320 320 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 321 321 struct __attribute__ ((unused)) __anonymous3 { -
tests/function-operator.c
r9aa9126 r7a7ab42 10 10 // Created On : Fri Aug 25 15:21:11 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 2 09:27:53 201813 // Update Count : 812 // Last Modified On : Thu Dec 7 12:42:26 2017 13 // Update Count : 6 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);173 170 } 174 171 -
tests/sum.c
r9aa9126 r7a7ab42 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Aug 2 08:03:09201814 // Update Count : 27 913 // Last Modified On : Sun Jun 3 19:23:41 2018 14 // Update Count : 278 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 );118 117 } // main 119 118 -
tests/tuple/tupleVariadic.c
r9aa9126 r7a7ab42 9 9 // Author : Rob Schluntz 10 10 // Created On : Fri Dec 16 10:25:35 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Aug 2 09:24:04 201813 // Update Count : 611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 21 14:42:48 2016 13 // Update Count : 2 14 14 // 15 16 #include <stdlib>17 15 18 16 void func(void) { … … 30 28 printf("called process(double) %g\n", x); 31 29 } 30 31 forall( dtype T, ttype Params | sized(T) | { void ?{}(T &, Params); } ) 32 T * new(Params p); 32 33 33 34 struct array { … … 65 66 a.data[2] = a2; 66 67 printf("called ?{} with a: %d %d %d\n", a0, a1, a2); 67 }68 69 void ^?{}(array & a) {70 free(a.data);71 68 } 72 69 … … 129 126 bar(x); 130 127 } 131 132 delete(ptr);133 delete(x4);134 delete(x3);135 delete(x2);136 delete(x1);137 delete(x0);138 128 } 139 129 … … 141 131 // tab-width: 4 // 142 132 // End: // 133
Note:
See TracChangeset
for help on using the changeset viewer.