Changeset be8bd88
- Timestamp:
- Mar 8, 2017, 3:22:50 PM (6 years ago)
- Branches:
- aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 031a2c95, 0e7ea335
- Parents:
- 87c3bef (diff), 6363ad1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 5 deleted
- 57 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r87c3bef rbe8bd88 30 30 31 31 src/prelude/builtins.cf 32 src/prelude/builtins.c 32 33 src/prelude/extras.cf 33 34 src/prelude/bootloader.c … … 36 37 # generated by bison and lex from cfa.yy and lex.ll, respectively 37 38 src/Parser/parser.output 39 src/Parser/lex.cc 40 src/Parser/parser.cc 41 src/Parser/parser.h 38 42 39 43 # generated by xfig for user manual -
Makefile.in
r87c3bef rbe8bd88 135 135 CFA_INCDIR = @CFA_INCDIR@ 136 136 CFA_LIBDIR = @CFA_LIBDIR@ 137 CFA_NAME = @CFA_NAME@ 137 138 CFA_PREFIX = @CFA_PREFIX@ 138 139 CFLAGS = @CFLAGS@ -
configure
r87c3bef rbe8bd88 668 668 CFA_BACKEND_CC 669 669 BACKEND_CC 670 CFA_NAME 670 671 MAINT 671 672 MAINTAINER_MODE_FALSE … … 741 742 enable_silent_rules 742 743 enable_maintainer_mode 744 with_cfa_name 743 745 with_backend_compiler 744 746 enable_target_release … … 1397 1399 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 1398 1400 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 1401 --with-cfa-name=NAME NAME too which cfa will be installed 1399 1402 --with-backend-compiler=PROGRAM PROGRAM that performs the final code compilation (must be gcc-compatible) 1400 1403 … … 3001 3004 # may require auto* software to be installed 3002 3005 3006 # Allow program name tansformation 3007 # will fille program_transform_name with appropriate sed regex 3008 3009 #autoconf escapes $ and \ since automake wiill un-escape them. 3010 #Since we need to use the sed transform in autoconf we need to manualy un-escape these characters 3011 name_transform=`echo ${program_transform_name} | sed 's/\\$\\$/\\$/g' | sed 's/\\\\\\\/\\\/g'` 3012 cfa_name=`echo cfa | sed ${name_transform}` 3013 cc1_name=`echo cc1 | sed ${name_transform}` 3014 cpp_name=`echo cfa-cpp | sed ${name_transform}` 3015 3016 #Trasforming cc1 will break compilation 3017 if ! test "${cc1_name}" = "cc1"; then 3018 as_fn_error $? "Program transform must not modify cc1. 3019 --program-sufix and --program-prefix not supported. 3020 Use -program-transform-name='s/cfa$/[Desired name here]/' instead" "$LINENO" 5 3021 fi 3022 #We could support transforming cfa-cpp but since it is located in a unique subfolder we don't need to 3023 if ! test "${cpp_name}" = "cfa-cpp"; then 3024 as_fn_error $? "Program transform must not modify cfa-cpp. 3025 --program-sufix and --program-prefix not supported. 3026 Use -program-transform-name='s/cfa$/[Desired name here]/' instead" "$LINENO" 5 3027 fi 3028 3029 3030 # Check whether --with-cfa-name was given. 3031 if test "${with_cfa_name+set}" = set; then : 3032 withval=$with_cfa_name; cfa_name=$withval 3033 else 3034 cfa_name="cfa" 3035 fi 3036 3037 3038 #Define the new name of the installed command 3039 CFA_NAME=${cfa_name} 3040 3041 3003 3042 rm -f version 3004 3043 echo ${PACKAGE_VERSION} > version # file containing version number for other tools … … 3238 3277 3239 3278 if test "$includedir" = '${prefix}/include'; then 3240 cfa_incdir="${cfa_prefix}/include/ cfa"3279 cfa_incdir="${cfa_prefix}/include/${cfa_name}" 3241 3280 else 3242 3281 cfa_incdir=${includedir} … … 3264 3303 3265 3304 if test "$libdir" = '${exec_prefix}/lib'; then 3266 cfa_libdir= ${cfa_prefix}/lib3305 cfa_libdir="${cfa_prefix}/lib/${cfa_name}" 3267 3306 else 3268 3307 cfa_libdir=${libdir} -
configure.ac
r87c3bef rbe8bd88 17 17 AM_INIT_AUTOMAKE 18 18 AM_MAINTAINER_MODE(enable) # may require auto* software to be installed 19 20 # Allow program name tansformation 21 # will fill program_transform_name with appropriate sed regex 22 AC_ARG_PROGRAM 23 24 #Trasforming cc1 will break compilation 25 if ! test "${program_transform_name}" = ""; then 26 AC_MSG_ERROR([Program transform not supported. 27 Use --with-cfa-name='[[Desired name here]]' instead]) 28 fi 29 30 AC_ARG_WITH(cfa-name, 31 [ --with-cfa-name=NAME NAME too which cfa will be installed], 32 cfa_name=$withval, cfa_name="cfa") 33 34 #Define the new name of the installed command 35 AC_SUBST(CFA_NAME, ${cfa_name}) 19 36 20 37 rm -f version … … 129 146 130 147 if test "$includedir" = '${prefix}/include'; then 131 cfa_incdir="${cfa_prefix}/include/ cfa"148 cfa_incdir="${cfa_prefix}/include/${cfa_name}" 132 149 else 133 150 cfa_incdir=${includedir} … … 145 162 146 163 if test "$libdir" = '${exec_prefix}/lib'; then 147 cfa_libdir= ${cfa_prefix}/lib164 cfa_libdir="${cfa_prefix}/lib/${cfa_name}" 148 165 else 149 166 cfa_libdir=${libdir} -
src/CodeGen/CodeGenerator.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 14:56:29201713 // Update Count : 4 1812 // Last Modified On : Sun Mar 5 17:13:33 2017 13 // Update Count : 475 14 14 // 15 15 … … 134 134 135 135 handleStorageClass( functionDecl ); 136 if ( functionDecl->get_isInline() ) { 137 output << "inline "; 138 } // if 139 if ( functionDecl->get_isNoreturn() ) { 140 output << "_Noreturn "; 141 } // if 136 DeclarationNode::print_FuncSpec( output, functionDecl->get_funcSpec() ); 137 142 138 output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), pretty ); 143 139 … … 835 831 } 836 832 837 838 833 void CodeGenerator::visit( ReturnStmt * returnStmt ) { 839 834 output << "return "; … … 899 894 } 900 895 901 void CodeGenerator::handleStorageClass( Declaration * decl ) { 902 switch ( decl->get_storageClass() ) { 903 case DeclarationNode::Extern: 904 output << "extern "; 905 break; 906 case DeclarationNode::Static: 907 output << "static "; 908 break; 909 case DeclarationNode::Auto: 910 // silently drop storage class 911 break; 912 case DeclarationNode::Register: 913 output << "register "; 914 break; 915 case DeclarationNode::Inline: 916 output << "inline "; 917 break; 918 case DeclarationNode::Fortran: 919 output << "fortran "; 920 break; 921 case DeclarationNode::Noreturn: 922 output << "_Noreturn "; 923 break; 924 case DeclarationNode::Threadlocal: 925 output << "_Thread_local "; 926 break; 927 case DeclarationNode::NoStorageClass: 928 break; 929 } // switch 930 } 896 void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) { 897 if ( decl->get_storageClasses().any() ) { 898 DeclarationNode::print_StorageClass( output, decl->get_storageClasses() ); 899 } // if 900 } // CodeGenerator::handleStorageClass 931 901 932 902 std::string genName( DeclarationWithType * decl ) { -
src/CodeGen/CodeGenerator.h
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 9 15:06:21201713 // Update Count : 4912 // Last Modified On : Wed Mar 1 16:20:04 2017 13 // Update Count : 50 14 14 // 15 15 … … 123 123 124 124 void printDesignators( std::list< Expression * > & ); 125 void handleStorageClass( Declaration *decl );125 void handleStorageClass( DeclarationWithType *decl ); 126 126 void handleAggregate( AggregateDecl *aggDecl ); 127 127 void handleTypedef( NamedTypeDecl *namedType ); -
src/CodeGen/FixNames.cc
r87c3bef rbe8bd88 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon Apr 11 15:38:10 201613 // Update Count : 1 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:32:08 2017 13 // Update Count : 15 14 14 // 15 15 … … 39 39 std::string mangle_main() { 40 40 FunctionType* main_type; 41 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( 42 "main", 43 DeclarationNode::NoStorageClass, 44 LinkageSpec::Cforall, 45 main_type = new FunctionType( Type::Qualifiers(), true ), 46 nullptr, false, false 47 ) }; 41 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 42 main_type = new FunctionType( Type::Qualifiers(), true ), nullptr ) 43 }; 48 44 main_type->get_returnVals().push_back( 49 new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )45 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 50 46 ); 51 47 52 auto && name = SymTab::Mangler::mangle( mainDecl.get() );48 auto && name = SymTab::Mangler::mangle( mainDecl.get() ); 53 49 // std::cerr << name << std::endl; 54 50 return name; … … 56 52 std::string mangle_main_args() { 57 53 FunctionType* main_type; 58 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( 59 "main", 60 DeclarationNode::NoStorageClass, 61 LinkageSpec::Cforall, 62 main_type = new FunctionType( Type::Qualifiers(), false ), 63 nullptr, false, false 64 ) }; 54 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 55 main_type = new FunctionType( Type::Qualifiers(), false ), nullptr ) 56 }; 65 57 main_type->get_returnVals().push_back( 66 new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )58 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 67 59 ); 68 60 69 61 mainDecl->get_functionType()->get_parameters().push_back( 70 new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )62 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 71 63 ); 72 64 73 65 mainDecl->get_functionType()->get_parameters().push_back( 74 new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0,66 new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, 75 67 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 76 68 nullptr ) -
src/GenPoly/Box.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 14:57:16201713 // Update Count : 29712 // Last Modified On : Mon Mar 6 23:45:59 2017 13 // Update Count : 330 14 14 // 15 15 … … 289 289 TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param ); 290 290 std::string paramName = mangleType( ¶mType ); 291 layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );292 layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );291 layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) ); 292 layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) ); 293 293 } 294 294 } … … 298 298 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 299 299 // because each unit generates copies of the default routines for each aggregate. 300 FunctionDecl *layoutDecl = new FunctionDecl( 301 layoutofName( typeDecl ), functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), true, false ); 300 FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ), 301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), 302 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), 303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ); 302 304 layoutDecl->fixUniqueId(); 303 305 return layoutDecl; … … 366 368 PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType ); 367 369 368 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );370 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 ); 369 371 layoutFnType->get_parameters().push_back( sizeParam ); 370 ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );372 ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 371 373 layoutFnType->get_parameters().push_back( alignParam ); 372 ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );374 ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 373 375 layoutFnType->get_parameters().push_back( offsetParam ); 374 376 addOtypeParams( layoutFnType, otypeParams ); … … 427 429 PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType ); 428 430 429 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );431 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 ); 430 432 layoutFnType->get_parameters().push_back( sizeParam ); 431 ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );433 ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 432 434 layoutFnType->get_parameters().push_back( alignParam ); 433 435 addOtypeParams( layoutFnType, otypeParams ); … … 535 537 if ( adapters.find( mangleName ) == adapters.end() ) { 536 538 std::string adapterName = makeAdapterName( mangleName ); 537 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, DeclarationNode:: NoStorageClass, LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), nullptr ) ) );539 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), nullptr ) ) ); 538 540 } // if 539 541 } // for … … 654 656 655 657 ObjectDecl *Pass1::makeTemporary( Type *type ) { 656 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, type, 0 );658 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, type, 0 ); 657 659 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 658 660 return newObj; … … 763 765 Type * newType = param->clone(); 764 766 if ( env ) env->apply( newType ); 765 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, newType, 0 );767 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, newType, 0 ); 766 768 newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right??? 767 769 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); … … 829 831 makeRetParm( adapter ); 830 832 } // if 831 adapter->get_parameters().push_front( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) );833 adapter->get_parameters().push_front( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) ); 832 834 return adapter; 833 835 } … … 910 912 adapterBody->get_kids().push_back( bodyStmt ); 911 913 std::string adapterName = makeAdapterName( mangleName ); 912 return new FunctionDecl( adapterName, DeclarationNode:: NoStorageClass, LinkageSpec::C, adapterType, adapterBody, false, false);914 return new FunctionDecl( adapterName, DeclarationNode::StorageClasses(), LinkageSpec::C, adapterType, adapterBody ); 913 915 } 914 916 … … 1271 1273 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 1272 1274 std::string adapterName = makeAdapterName( mangleName ); 1273 paramList.push_front( new ObjectDecl( adapterName, DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );1275 paramList.push_front( new ObjectDecl( adapterName, DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) ); 1274 1276 adaptersDone.insert( adaptersDone.begin(), mangleName ); 1275 1277 } … … 1377 1379 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1378 1380 std::list< DeclarationWithType *> inferredParams; 1379 ObjectDecl newObj( "", DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );1380 ObjectDecl newPtr( "", DeclarationNode:: NoStorageClass, LinkageSpec::C, 0,1381 ObjectDecl newObj( "", DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1382 ObjectDecl newPtr( "", DeclarationNode::StorageClasses(), LinkageSpec::C, 0, 1381 1383 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); 1382 1384 for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { … … 1632 1634 1633 1635 ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) { 1634 ObjectDecl *newObj = new ObjectDecl( name, DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, type, init );1636 ObjectDecl *newObj = new ObjectDecl( name, DeclarationNode::StorageClasses(), LinkageSpec::C, 0, type, init ); 1635 1637 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 1636 1638 return newObj; … … 1816 1818 memberDecl = origMember->clone(); 1817 1819 } else { 1818 memberDecl = new ObjectDecl( (*member)->get_name(), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, offsetType->clone(), 0 );1820 memberDecl = new ObjectDecl( (*member)->get_name(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, offsetType->clone(), 0 ); 1819 1821 } 1820 1822 inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) ); -
src/GenPoly/Specialize.cc
r87c3bef rbe8bd88 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Apr 28 15:17:45 201613 // Update Count : 2411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:13:00 2017 13 // Update Count : 30 14 14 // 15 15 … … 155 155 } // if 156 156 // create new thunk with same signature as formal type (C linkage, empty body) 157 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, newType, new CompoundStmt( noLabels ), false, false);157 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels ) ); 158 158 thunkFunc->fixUniqueId(); 159 159 -
src/InitTweak/FixGlobalInit.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 29 22:33:15 201613 // Update Count : 412 // Last Modified On : Mon Mar 6 23:14:19 2017 13 // Update Count : 14 14 14 // 15 15 … … 87 87 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 88 88 } 89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::St atic, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false);89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 90 90 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::St atic, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false);91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 92 92 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 93 93 } -
src/InitTweak/FixInit.cc
r87c3bef rbe8bd88 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 14:58:43201713 // Update Count : 3512 // Last Modified On : Tue Mar 7 07:51:40 2017 13 // Update Count : 59 14 14 // 15 15 … … 437 437 result = result->clone(); 438 438 env->apply( result ); 439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, result, 0 );439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 440 440 tmp->get_type()->set_isConst( false ); 441 441 … … 483 483 result = result->clone(); 484 484 env->apply( result ); 485 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, result, 0 );485 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 486 486 ret->get_type()->set_isConst( false ); 487 487 impCpCtorExpr->get_returnDecls().push_back( ret ); … … 506 506 result = result->clone(); 507 507 env->apply( result ); 508 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, result, 0 );508 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 509 509 ret->get_type()->set_isConst( false ); 510 510 stmtExpr->get_returnDecls().push_front( ret ); … … 538 538 } else { 539 539 // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression 540 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), DeclarationNode:: NoStorageClass, LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );540 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) ); 541 541 unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) ); 542 542 } … … 678 678 assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() ); 679 679 if ( Statement * ctor = ctorInit->get_ctor() ) { 680 if ( objDecl->get_storageClass () == DeclarationNode::Static) {680 if ( objDecl->get_storageClasses()[ DeclarationNode::Static ] ) { 681 681 // originally wanted to take advantage of gcc nested functions, but 682 682 // we get memory errors with this approach. To remedy this, the static … … 704 704 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 705 705 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators ); 706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::St atic, LinkageSpec::Cforall, 0, boolType, boolInitExpr );706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::Cforall, 0, boolType, boolInitExpr ); 707 707 isUninitializedVar->fixUniqueId(); 708 708 … … 731 731 732 732 // void __objName_dtor_atexitN(...) {...} 733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::St atic, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false);733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 734 734 dtorCaller->fixUniqueId(); 735 735 dtorCaller->get_statements()->push_back( dtorStmt ); … … 764 764 // create a new object which is never used 765 765 static UniqueName dummyNamer( "_dummy" ); 766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::St atic, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } ); 767 767 return dummy; 768 768 } … … 821 821 void InsertDtors::visit( ObjectDecl * objDecl ) { 822 822 // remember non-static destructed objects so that their destructors can be inserted later 823 if ( objDecl->get_storageClass() != DeclarationNode::Static) {823 if ( ! objDecl->get_storageClasses()[ DeclarationNode::Static ] ) { 824 824 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 825 825 // a decision should have been made by the resolver, so ctor and init are not both non-NULL … … 1118 1118 1119 1119 // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary. 1120 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );1120 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr ); 1121 1121 addDeclaration( tmp ); 1122 1122 -
src/InitTweak/GenInit.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 14:57:53201713 // Update Count : 1 6712 // Last Modified On : Tue Mar 7 07:51:38 2017 13 // Update Count : 179 14 14 // 15 15 … … 120 120 void hoist( Type * type ); 121 121 122 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;122 DeclarationNode::StorageClasses storageClasses; 123 123 bool inFunction = false; 124 124 }; … … 174 174 175 175 DeclarationWithType * HoistArrayDimension::mutate( ObjectDecl * objectDecl ) { 176 storage class = objectDecl->get_storageClass();176 storageClasses = objectDecl->get_storageClasses(); 177 177 DeclarationWithType * temp = Parent::mutate( objectDecl ); 178 178 hoist( objectDecl->get_type() ); 179 storageclass = DeclarationNode::NoStorageClass;180 179 return temp; 181 180 } … … 185 184 static UniqueName dimensionName( "_array_dim" ); 186 185 187 // C doesn't allow variable sized arrays at global scope or for static variables, 188 // so don't hoist dimension. 186 // C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension. 189 187 if ( ! inFunction ) return; 190 if ( storage class == DeclarationNode::Static) return;188 if ( storageClasses[ DeclarationNode::StaticClass] ) return; 191 189 192 190 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { 193 191 if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist? 194 192 195 // don't need to hoist dimension if it's a constexpr - only need to if there's potential 196 // for side effects. 193 // don't need to hoist dimension if it's a constexpr - only need to if there's potential for side effects. 197 194 if ( isConstExpr( arrayType->get_dimension() ) ) return; 198 195 199 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storage class, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );196 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) ); 200 197 arrayDimension->get_type()->set_isConst( true ); 201 198 -
src/InitTweak/InitTweak.cc
r87c3bef rbe8bd88 260 260 (objDecl->get_init() == NULL || 261 261 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) 262 && objDecl->get_storageClass() != DeclarationNode::Extern;262 && ! objDecl->get_storageClasses()[ DeclarationNode::Extern ]; 263 263 } 264 264 -
src/Makefile.am
r87c3bef rbe8bd88 38 38 39 39 # put into lib for now 40 cfa_cpplibdir = ${ libdir}40 cfa_cpplibdir = ${CFA_LIBDIR} 41 41 cfa_cpplib_PROGRAMS = driver/cfa-cpp 42 42 driver_cfa_cpp_SOURCES = ${SRC} -
src/Makefile.in
r87c3bef rbe8bd88 276 276 CFA_INCDIR = @CFA_INCDIR@ 277 277 CFA_LIBDIR = @CFA_LIBDIR@ 278 CFA_NAME = @CFA_NAME@ 278 279 CFA_PREFIX = @CFA_PREFIX@ 279 280 CFLAGS = @CFLAGS@ … … 436 437 437 438 # put into lib for now 438 cfa_cpplibdir = ${ libdir}439 cfa_cpplibdir = ${CFA_LIBDIR} 439 440 driver_cfa_cpp_SOURCES = ${SRC} 440 441 driver_cfa_cpp_LDADD = ${LEXLIB} -ldl # yywrap -
src/Parser/DeclarationNode.cc
r87c3bef rbe8bd88 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 23 22:21:06201713 // Update Count : 77512 // Last Modified On : Tue Mar 7 08:02:09 2017 13 // Update Count : 936 14 14 // 15 15 … … 19 19 #include <algorithm> 20 20 #include <cassert> 21 #include <strings.h> // ffs 21 22 22 23 #include "TypeData.h" … … 32 33 33 34 // These must remain in the same order as the corresponding DeclarationNode enumerations. 34 const char * DeclarationNode::storageName[] = { "extern", "static", "auto", "register", "inline", "fortran", "_Noreturn", "_Thread_local", "NoStorageClass" }; 35 const char * DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic", "NoQualifier" }; 36 const char * DeclarationNode::basicTypeName[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicType" }; 37 const char * DeclarationNode::complexTypeName[] = { "_Complex", "_Imaginary", "NoComplexType" }; 38 const char * DeclarationNode::signednessName[] = { "signed", "unsigned", "NoSignedness" }; 39 const char * DeclarationNode::lengthName[] = { "short", "long", "long long", "NoLength" }; 40 const char * DeclarationNode::aggregateName[] = { "struct", "union", "context" }; 41 const char * DeclarationNode::typeClassName[] = { "otype", "dtype", "ftype" }; 42 const char * DeclarationNode::builtinTypeName[] = { "__builtin_va_list" }; 35 const char * DeclarationNode::storageClassNames[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" }; 36 const char * DeclarationNode::funcSpecifierNames[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" }; 37 const char * DeclarationNode::typeQualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" }; 38 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" }; 39 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" }; 40 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 41 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 42 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "context", "NoAggregateNames" }; 43 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 44 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "NoBuiltinTypeNames" }; 43 45 44 46 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 48 50 DeclarationNode::DeclarationNode() : 49 51 type( nullptr ), 50 storageClass( NoStorageClass ),51 52 bitfieldWidth( nullptr ), 52 isInline( false ),53 isNoreturn( false ),54 53 hasEllipsis( false ), 55 54 linkage( ::linkage ), … … 90 89 91 90 newnode->type = maybeClone( type ); 92 newnode->storageClass = storageClass;91 newnode->storageClasses = storageClasses; 93 92 newnode->bitfieldWidth = maybeClone( bitfieldWidth ); 94 newnode->isInline = isInline; 95 newnode->isNoreturn = isNoreturn; 93 newnode->funcSpecs = funcSpecs; 96 94 newnode->enumeratorValue.reset( maybeClone( enumeratorValue.get() ) ); 97 95 newnode->hasEllipsis = hasEllipsis; … … 118 116 } 119 117 118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) { 119 if ( storageClasses.any() ) { // function specifiers? 120 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) { 121 if ( storageClasses[i] ) { 122 output << DeclarationNode::storageClassNames[i] << ' '; 123 } // if 124 } // for 125 } // if 126 } // print_StorageClass 127 128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) { 129 if ( funcSpec.any() ) { // function specifiers? 130 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) { 131 if ( funcSpec[i] ) { 132 output << DeclarationNode::funcSpecifierNames[i] << ' '; 133 } // if 134 } // for 135 } // if 136 } // print_FuncSpec 137 120 138 void DeclarationNode::print( std::ostream &os, int indent ) const { 121 139 os << string( indent, ' ' ); … … 130 148 } // if 131 149 132 if ( storageClass != NoStorageClass ) os << DeclarationNode::storageName[storageClass] << ' ';133 if ( isInline ) os << DeclarationNode::storageName[Inline] << ' ';134 if ( isNoreturn ) os << DeclarationNode::storageName[Noreturn] << ' '; 150 print_StorageClass( os, storageClasses ); 151 print_FuncSpec( os, funcSpecs ); 152 135 153 if ( type ) { 136 154 type->print( os, indent ); … … 183 201 } // DeclarationNode::newFunction 184 202 185 DeclarationNode * DeclarationNode::newQualifier( Qualifier q ) { 203 204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) { 205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses[ sc ] = true; 207 return newnode; 208 } // DeclarationNode::newStorageClass 209 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifier fs ) { 211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs[ fs ] = true; 213 return newnode; 214 } // DeclarationNode::newFuncSpecifier 215 216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) { 186 217 DeclarationNode * newnode = new DeclarationNode; 187 218 newnode->type = new TypeData(); 188 newnode->type-> qualifiers[ q ] = 1;219 newnode->type->typeQualifiers[ tq ] = true; 189 220 return newnode; 190 221 } // DeclarationNode::newQualifier 222 223 DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) { 224 DeclarationNode * newnode = new DeclarationNode; 225 newnode->type = new TypeData( TypeData::Basic ); 226 newnode->type->basictype = bt; 227 return newnode; 228 } // DeclarationNode::newBasicType 229 230 DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) { 231 DeclarationNode * newnode = new DeclarationNode; 232 newnode->type = new TypeData( TypeData::Basic ); 233 newnode->type->complextype = ct; 234 return newnode; 235 } // DeclarationNode::newComplexType 236 237 DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) { 238 DeclarationNode * newnode = new DeclarationNode; 239 newnode->type = new TypeData( TypeData::Basic ); 240 newnode->type->signedness = sn; 241 return newnode; 242 } // DeclarationNode::newSignedNess 243 244 DeclarationNode * DeclarationNode::newLength( Length lnth ) { 245 DeclarationNode * newnode = new DeclarationNode; 246 newnode->type = new TypeData( TypeData::Basic ); 247 newnode->type->length = lnth; 248 return newnode; 249 } // DeclarationNode::newLength 191 250 192 251 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) { … … 196 255 return newnode; 197 256 } // DeclarationNode::newForall 198 199 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {200 DeclarationNode * newnode = new DeclarationNode;201 newnode->storageClass = sc;202 return newnode;203 } // DeclarationNode::newStorageClass204 205 DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) {206 DeclarationNode * newnode = new DeclarationNode;207 newnode->type = new TypeData( TypeData::Basic );208 newnode->type->basictype = bt;209 return newnode;210 } // DeclarationNode::newBasicType211 212 DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) {213 DeclarationNode * newnode = new DeclarationNode;214 newnode->type = new TypeData( TypeData::Basic );215 newnode->type->complextype = ct;216 return newnode;217 } // DeclarationNode::newComplexType218 219 DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) {220 DeclarationNode * newnode = new DeclarationNode;221 newnode->type = new TypeData( TypeData::Basic );222 newnode->type->signedness = sn;223 return newnode;224 } // DeclarationNode::newSignedNess225 226 DeclarationNode * DeclarationNode::newLength( Length lnth ) {227 DeclarationNode * newnode = new DeclarationNode;228 newnode->type = new TypeData( TypeData::Basic );229 newnode->type->length = lnth;230 return newnode;231 } // DeclarationNode::newLength232 257 233 258 DeclarationNode * DeclarationNode::newFromTypedef( string * name ) { … … 428 453 429 454 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 430 TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization455 const TypeData::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization 431 456 432 457 if ( (qsrc & qdst).any() ) { // common qualifier ? 433 for ( int i = 0; i < NoQualifier; i += 1 ) {// find common qualifiers458 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find common qualifiers 434 459 if ( qsrc[i] && qdst[i] ) { 435 appendError( error, string( "duplicate " ) + DeclarationNode:: qualifierName[i] );460 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] ); 436 461 } // if 437 462 } // for 438 } // if463 } // for 439 464 } // DeclarationNode::checkQualifiers 440 465 441 void DeclarationNode::checkStorageClasses( DeclarationNode * q ) { 442 if ( storageClass != NoStorageClass && q->storageClass != NoStorageClass ) { 443 if ( storageClass == q->storageClass ) { // duplicate qualifier 444 appendError( error, string( "duplicate " ) + storageName[ storageClass ] ); 445 } else { // only one storage class 446 appendError( error, string( "conflicting " ) + storageName[ storageClass ] + " & " + storageName[ q->storageClass ] ); 447 q->storageClass = storageClass; // FIX ERROR, prevent assertions from triggering 448 } // if 449 } // if 450 appendError( error, q->error ); 451 } // DeclarationNode::checkStorageClasses 452 453 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode * q ) { 454 isInline = isInline || q->isInline; 455 isNoreturn = isNoreturn || q->isNoreturn; 456 // do not overwrite an existing value with NoStorageClass 457 if ( q->storageClass != NoStorageClass ) { 458 assert( storageClass == NoStorageClass || storageClass == q->storageClass ); 459 storageClass = q->storageClass; 460 } // if 466 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 467 if ( (funcSpecs & src->funcSpecs).any() ) { // common specifier ? 468 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find common specifier 469 if ( funcSpecs[i] && src->funcSpecs[i] ) { 470 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] ); 471 } // if 472 } // for 473 } // if 474 475 if ( storageClasses != 0 && src->storageClasses != 0 ) { // any reason to check ? 476 if ( (storageClasses & src->storageClasses).any() ) { // duplicates ? 477 for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates 478 if ( storageClasses[i] && src->storageClasses[i] ) { 479 appendError( error, string( "duplicate " ) + storageClassNames[i] ); 480 } // if 481 } // for 482 // src is the new item being added and has a single bit 483 } else if ( ! src->storageClasses[ Threadlocal ] ) { // conflict ? 484 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.to_ulong() ) - 1] + 485 " & " + storageClassNames[ffs( src->storageClasses.to_ulong() ) - 1] ); 486 src->storageClasses.reset(); // FIX to preserve invariant of one basic storage specifier 487 } // if 488 } // if 489 490 appendError( error, src->error ); 491 } // DeclarationNode::checkSpecifiers 492 493 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 494 funcSpecs = funcSpecs | q->funcSpecs; 495 storageClasses = storageClasses | q->storageClasses; 461 496 462 497 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 464 499 } // for 465 500 return this; 466 } // DeclarationNode::copyS torageClasses501 } // DeclarationNode::copySpecifiers 467 502 468 503 static void addQualifiersToType( TypeData *&src, TypeData * dst ) { … … 481 516 src = nullptr; 482 517 } else { 483 dst-> qualifiers |= src->qualifiers;518 dst->typeQualifiers |= src->typeQualifiers; 484 519 } // if 485 520 } // addQualifiersToType … … 488 523 if ( ! q ) { delete q; return this; } 489 524 490 checkS torageClasses( q );491 copyS torageClasses( q );525 checkSpecifiers( q ); 526 copySpecifiers( q ); 492 527 493 528 if ( ! q->type ) { … … 518 553 } // if 519 554 520 checkQualifiers( q->type,type );555 checkQualifiers( type, q->type ); 521 556 addQualifiersToType( q->type, type ); 522 557 … … 539 574 switch ( dst->kind ) { 540 575 case TypeData::Unknown: 541 src-> qualifiers |= dst->qualifiers;576 src->typeQualifiers |= dst->typeQualifiers; 542 577 dst = src; 543 578 src = nullptr; 544 579 break; 545 580 case TypeData::Basic: 546 dst-> qualifiers |= src->qualifiers;581 dst->typeQualifiers |= src->typeQualifiers; 547 582 if ( src->kind != TypeData::Unknown ) { 548 583 assert( src->kind == TypeData::Basic ); … … 551 586 dst->basictype = src->basictype; 552 587 } else if ( src->basictype != DeclarationNode::NoBasicType ) 553 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeName [ src->basictype ] + " in type: ", src );588 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: ", src ); 554 589 555 590 if ( dst->complextype == DeclarationNode::NoComplexType ) { 556 591 dst->complextype = src->complextype; 557 592 } else if ( src->complextype != DeclarationNode::NoComplexType ) 558 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeName [ src->complextype ] + " in type: ", src );593 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: ", src ); 559 594 560 595 if ( dst->signedness == DeclarationNode::NoSignedness ) { 561 596 dst->signedness = src->signedness; 562 597 } else if ( src->signedness != DeclarationNode::NoSignedness ) 563 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessName [ src->signedness ] + " in type: ", src );598 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: ", src ); 564 599 565 600 if ( dst->length == DeclarationNode::NoLength ) { … … 568 603 dst->length = DeclarationNode::LongLong; 569 604 } else if ( src->length != DeclarationNode::NoLength ) 570 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthName [ src->length ] + " in type: ", src );605 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: ", src ); 571 606 } // if 572 607 break; … … 580 615 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 581 616 } // if 582 dst->base-> qualifiers |= src->qualifiers;617 dst->base->typeQualifiers |= src->typeQualifiers; 583 618 src = nullptr; 584 619 break; … … 599 634 DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) { 600 635 if ( o ) { 601 checkS torageClasses( o );602 copyS torageClasses( o );636 checkSpecifiers( o ); 637 copySpecifiers( o ); 603 638 if ( o->type ) { 604 639 if ( ! type ) { … … 612 647 type->aggInst.hoistType = o->type->enumeration.body; 613 648 } // if 614 type-> qualifiers |= o->type->qualifiers;649 type->typeQualifiers |= o->type->typeQualifiers; 615 650 } else { 616 651 type = o->type; … … 768 803 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 769 804 } // if 770 p->type->base-> qualifiers |= type->qualifiers;805 p->type->base->typeQualifiers |= type->typeQualifiers; 771 806 break; 772 807 … … 805 840 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 806 841 } // if 807 lastArray->base-> qualifiers |= type->qualifiers;842 lastArray->base->typeQualifiers |= type->typeQualifiers; 808 843 break; 809 844 default: … … 854 889 DeclarationNode * newnode = new DeclarationNode; 855 890 newnode->type = maybeClone( type ); 856 assert( storageClass == NoStorageClass ); 857 newnode->copyStorageClasses( this ); 891 newnode->copySpecifiers( this ); 858 892 assert( newName ); 859 893 newnode->name = newName; … … 864 898 if ( ! o ) return nullptr; 865 899 866 o->copyS torageClasses( this );900 o->copySpecifiers( this ); 867 901 if ( type ) { 868 902 TypeData * srcType = type; … … 956 990 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 957 991 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 958 auto obj = new ObjectDecl( "", DeclarationNode:: NoStorageClass, linkage, nullptr, inst, nullptr );992 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr ); 959 993 obj->location = cur->location; 960 994 * out++ = obj; … … 962 996 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 963 997 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 964 auto obj = new ObjectDecl( "", DeclarationNode:: NoStorageClass, linkage, nullptr, inst, nullptr );998 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr ); 965 999 obj->location = cur->location; 966 1000 * out++ = obj; … … 1005 1039 } // if 1006 1040 1007 // if ( variable.name ) {1008 1041 if ( variable.tyClass != NoTypeClass ) { 1009 1042 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1010 1043 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1011 1044 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1012 // TypeDecl * ret = new TypeDecl( *variable.name, DeclarationNode::NoStorageClass, nullptr, kindMap[ variable.tyClass ] ); 1013 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::NoStorageClass, nullptr, kindMap[ variable.tyClass ] ); 1045 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] ); 1014 1046 buildList( variable.assertions, ret->get_assertions() ); 1015 1047 return ret; … … 1017 1049 1018 1050 if ( type ) { 1019 return buildDecl( type, name ? *name : string( "" ), storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension ); 1020 } // if 1021 1022 if ( ! isInline && ! isNoreturn ) { 1023 assertf( name, "ObjectDecl are assumed to have names\n" ); 1024 return (new ObjectDecl( *name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_asmName( asmName )->set_extension( extension ); 1025 } // if 1026 1027 throw SemanticError( "invalid function specifier ", this ); 1051 // Function specifiers can only appear on a function definition/declaration. 1052 // 1053 // inline _Noreturn int f(); // allowed 1054 // inline _Noreturn int g( int i ); // allowed 1055 // inline _Noreturn int i; // disallowed 1056 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1057 throw SemanticError( "invalid function specifier for ", this ); 1058 } // if 1059 return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension ); 1060 } // if 1061 1062 // SUE's cannot have function specifiers, either 1063 // 1064 // inlne _Noreturn struct S { ... }; // disallowed 1065 // inlne _Noreturn enum E { ... }; // disallowed 1066 if ( funcSpecs.any() ) { 1067 throw SemanticError( "invalid function specifier for ", this ); 1068 } // if 1069 assertf( name, "ObjectDecl must a have name\n" ); 1070 return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild< Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_asmName( asmName )->set_extension( extension ); 1028 1071 } 1029 1072 … … 1032 1075 1033 1076 if ( attr.expr ) { 1034 // return new AttrType( buildQualifiers( type ), *attr.name, attr.expr->build() );1035 1077 return new AttrType( buildQualifiers( type ), *name, attr.expr->build(), attributes ); 1036 1078 } else if ( attr.type ) { 1037 // return new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() );1038 1079 return new AttrType( buildQualifiers( type ), *name, attr.type->buildType(), attributes ); 1039 1080 } // if -
src/Parser/ExpressionNode.cc
r87c3bef rbe8bd88 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 16 16:27:44 201613 // Update Count : 50 812 // Last Modified On : Sat Mar 4 06:58:47 2017 13 // Update Count : 509 14 14 // 15 15 … … 173 173 174 174 Expression *build_constantZeroOne( const std::string & str ) { 175 Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str ) );175 Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str ) ); 176 176 delete &str; // created by lex 177 177 return ret; … … 275 275 } 276 276 Expression *build_offsetOf( DeclarationNode *decl_node, NameExpr *member ) { 277 Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );277 Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() ); 278 278 delete member; 279 279 return ret; -
src/Parser/ParseNode.h
r87c3bef rbe8bd88 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 23 15:22:10201713 // Update Count : 66212 // Last Modified On : Tue Mar 7 08:10:53 2017 13 // Update Count : 726 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset> 21 22 #include <iterator> 22 23 #include <memory> … … 39 40 //############################################################################## 40 41 41 extern char * yyfilename;42 extern char * yyfilename; 42 43 extern int yylineno; 43 44 … … 122 123 } 123 124 124 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }125 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); } 125 126 private: 126 127 bool extension = false; … … 203 204 // These must remain in the same order as the corresponding DeclarationNode names. 204 205 205 // enum StorageClass { Extern, Static, Auto, Register, NoStorageClass }; 206 // enum FunctionSpec { Inline, Fortran, Noreturn, NoFunctionSpec }; 207 // enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, Threadlocal, Mutex, NoQualifier }; 208 209 enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran, Noreturn, Threadlocal, NoStorageClass, }; 210 enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, NoQualifier }; 206 enum StorageClass { Extern, Static, Auto, Register, Threadlocal, NoStorageClass, 207 ExternClass = 1 << Extern, StaticClass = 1 << Static, AutoClass = 1 << Auto, RegisterClass = 1 << Register, ThreadlocalClass = 1 << Threadlocal }; 208 enum FuncSpecifier { Inline, Noreturn, Fortran, NoFuncSpecifier, 209 InlineSpec = 1 << Inline, NoreturnSpec = 1 << Noreturn, FortranSpec = 1 << Fortran }; 210 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier }; 211 211 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 212 212 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 217 217 enum BuiltinType { Valist, Zero, One, NoBuiltinType }; 218 218 219 static const char * storageName[]; 220 static const char * qualifierName[]; 221 static const char * basicTypeName[]; 222 static const char * complexTypeName[]; 223 static const char * signednessName[]; 224 static const char * lengthName[]; 225 static const char * aggregateName[]; 226 static const char * typeClassName[]; 227 static const char * builtinTypeName[]; 228 229 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false ); 230 static DeclarationNode * newQualifier( Qualifier ); 231 static DeclarationNode * newForall( DeclarationNode * ); 219 static const char * storageClassNames[]; 220 static const char * funcSpecifierNames[]; 221 static const char * typeQualifierNames[]; 222 static const char * basicTypeNames[]; 223 static const char * complexTypeNames[]; 224 static const char * signednessNames[]; 225 static const char * lengthNames[]; 226 static const char * aggregateNames[]; 227 static const char * typeClassNames[]; 228 static const char * builtinTypeNames[]; 229 232 230 static DeclarationNode * newStorageClass( StorageClass ); 231 static DeclarationNode * newFuncSpecifier( FuncSpecifier ); 232 static DeclarationNode * newTypeQualifier( TypeQualifier ); 233 233 static DeclarationNode * newBasicType( BasicType ); 234 234 static DeclarationNode * newComplexType( ComplexType ); 235 static DeclarationNode * newSignedNess( Signedness sn);236 static DeclarationNode * newLength( Length lnth);235 static DeclarationNode * newSignedNess( Signedness ); 236 static DeclarationNode * newLength( Length ); 237 237 static DeclarationNode * newBuiltinType( BuiltinType ); 238 static DeclarationNode * newForall( DeclarationNode * ); 238 239 static DeclarationNode * newFromTypedef( std::string * ); 240 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false ); 239 241 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 240 242 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body ); … … 263 265 DeclarationNode * addQualifiers( DeclarationNode * ); 264 266 void checkQualifiers( const TypeData *, const TypeData * ); 265 void checkS torageClasses( DeclarationNode * );266 DeclarationNode * copyS torageClasses( DeclarationNode * );267 void checkSpecifiers( DeclarationNode * ); 268 DeclarationNode * copySpecifiers( DeclarationNode * ); 267 269 DeclarationNode * addType( DeclarationNode * ); 268 270 DeclarationNode * addTypedef(); … … 295 297 296 298 Declaration * build() const; 297 ::Type * buildType() const;299 Type * buildType() const; 298 300 299 301 bool get_hasEllipsis() const; … … 301 303 DeclarationNode * extractAggregate() const; 302 304 bool has_enumeratorValue() const { return (bool)enumeratorValue; } 303 ExpressionNode * consume_enumeratorValue() const { return const_cast<DeclarationNode *>(this)->enumeratorValue.release(); }305 ExpressionNode * consume_enumeratorValue() const { return const_cast<DeclarationNode *>(this)->enumeratorValue.release(); } 304 306 305 307 bool get_extension() const { return extension; } … … 323 325 324 326 TypeData * type; 325 StorageClass storageClass; 327 328 typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses; 329 StorageClasses storageClasses; 330 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses ); 331 332 typedef std::bitset< DeclarationNode::NoFuncSpecifier > FuncSpecifiers; 333 FuncSpecifiers funcSpecs; 334 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs ); 335 326 336 ExpressionNode * bitfieldWidth; 327 bool isInline, isNoreturn;328 337 std::unique_ptr<ExpressionNode> enumeratorValue; 329 338 bool hasEllipsis; … … 342 351 343 352 static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) { 344 Type * ret = orig ? orig->buildType() : nullptr;353 Type * ret = orig ? orig->buildType() : nullptr; 345 354 delete orig; 346 355 return ret; … … 357 366 358 367 virtual StatementNode * clone() const final { assert( false ); return nullptr; } 359 Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }368 Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); } 360 369 361 370 virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) { -
src/Parser/TypeData.cc
r87c3bef rbe8bd88 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 23 21:48:55201713 // Update Count : 48512 // Last Modified On : Tue Mar 7 08:08:21 2017 13 // Update Count : 538 14 14 // 15 15 … … 157 157 TypeData * TypeData::clone() const { 158 158 TypeData * newtype = new TypeData( kind ); 159 newtype-> qualifiers = qualifiers;159 newtype->typeQualifiers = typeQualifiers; 160 160 newtype->base = maybeClone( base ); 161 161 newtype->forall = maybeClone( forall ); … … 226 226 227 227 void TypeData::print( ostream &os, int indent ) const { 228 for ( int i = 0; i < DeclarationNode::No Qualifier; i += 1 ) {229 if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' ';228 for ( int i = 0; i < DeclarationNode::NoTypeQualifier; i += 1 ) { 229 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' '; 230 230 } // for 231 231 … … 250 250 break; 251 251 case Basic: 252 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName [ signedness ] << " ";253 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName [ length ] << " ";252 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 253 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " "; 254 254 assert( basictype != DeclarationNode::NoBasicType ); 255 os << DeclarationNode::basicTypeName [ basictype ] << " ";256 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName [ complextype ] << " ";255 os << DeclarationNode::basicTypeNames[ basictype ] << " "; 256 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " "; 257 257 break; 258 258 case Array: … … 301 301 break; 302 302 case Aggregate: 303 os << DeclarationNode::aggregateName [ aggregate.kind ] << ' ' << *aggregate.name << endl;303 os << DeclarationNode::aggregateNames[ aggregate.kind ] << ' ' << *aggregate.name << endl; 304 304 if ( aggregate.params ) { 305 305 os << string( indent + 2, ' ' ) << "with type parameters " << endl; … … 393 393 buildList( firstNode, outputList ); 394 394 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 395 TypeDecl * td = static_cast<TypeDecl *>(*i);395 TypeDecl * td = static_cast<TypeDecl *>(*i); 396 396 if ( td->get_kind() == TypeDecl::Any ) { 397 397 // add assertion parameters to `type' tyvars in reverse order 398 398 // add dtor: void ^?{}(T *) 399 399 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 400 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );401 td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false) );400 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 401 td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) ); 402 402 403 403 // add copy ctor: void ?{}(T *, T) 404 404 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false ); 405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );407 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false) );405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 407 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) ); 408 408 409 409 // add default ctor: void ?{}(T *) 410 410 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 411 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );412 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false) );411 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 412 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) ); 413 413 414 414 // add assignment operator: T * ?=?(T *, T) 415 415 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false ); 416 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );417 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );418 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );419 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false) );416 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 417 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 418 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 419 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) ); 420 420 } // if 421 421 } // for … … 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 495 Type::Qualifiers q; 496 q.isConst = td-> qualifiers[ DeclarationNode::Const ];497 q.isVolatile = td-> qualifiers[ DeclarationNode::Volatile ];498 q.isRestrict = td-> qualifiers[ DeclarationNode::Restrict ];499 q.isLvalue = td-> qualifiers[ DeclarationNode::Lvalue ];500 q.isAtomic = td-> qualifiers[ DeclarationNode::Atomic ];;496 q.isConst = td->typeQualifiers[ DeclarationNode::Const ]; 497 q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ]; 498 q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ]; 499 q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ]; 500 q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];; 501 501 return q; 502 502 } // buildQualifiers … … 516 516 case DeclarationNode::Bool: 517 517 if ( td->signedness != DeclarationNode::NoSignedness ) { 518 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName [ td->signedness ] + " in type: ", td );518 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td ); 519 519 } // if 520 520 if ( td->length != DeclarationNode::NoLength ) { 521 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName [ td->length ] + " in type: ", td );521 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td ); 522 522 } // if 523 523 … … 532 532 533 533 if ( td->length != DeclarationNode::NoLength ) { 534 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName [ td->length ] + " in type: ", td );534 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td ); 535 535 } // if 536 536 … … 562 562 FloatingPoint: ; 563 563 if ( td->signedness != DeclarationNode::NoSignedness ) { 564 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName [ td->signedness ] + " in type: ", td );564 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td ); 565 565 } // if 566 566 if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) { 567 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName [ td->length ] + " in type: ", td );567 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td ); 568 568 } // if 569 569 if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) { … … 732 732 } // buildAggInst 733 733 734 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClass sc) {734 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClasses scs ) { 735 735 assert( td->kind == TypeData::Symbolic ); 736 736 NamedTypeDecl * ret; 737 737 assert( td->base ); 738 738 if ( td->symbolic.isTypedef ) { 739 ret = new TypedefDecl( name, sc , typebuild( td->base ) );739 ret = new TypedefDecl( name, scs, typebuild( td->base ) ); 740 740 } else { 741 ret = new TypeDecl( name, sc , typebuild( td->base ), TypeDecl::Any );741 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Any ); 742 742 } // if 743 743 buildList( td->symbolic.params, ret->get_parameters() ); … … 784 784 } // buildTypeof 785 785 786 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {786 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 787 787 if ( td->kind == TypeData::Function ) { 788 788 if ( td->function.idList ) { // KR function ? … … 792 792 FunctionDecl * decl; 793 793 Statement * stmt = maybeBuild<Statement>( td->function.body ); 794 CompoundStmt * body = dynamic_cast< CompoundStmt * >( stmt );795 decl = new FunctionDecl( name, sc , linkage, buildFunction( td ), body, isInline, isNoreturn, attributes);794 CompoundStmt * body = dynamic_cast< CompoundStmt * >( stmt ); 795 decl = new FunctionDecl( name, scs, linkage, buildFunction( td ), body, attributes, funcSpec ); 796 796 return decl->set_asmName( asmName ); 797 797 } else if ( td->kind == TypeData::Aggregate ) { … … 800 800 return buildEnum( td, attributes ); 801 801 } else if ( td->kind == TypeData::Symbolic ) { 802 return buildSymbolic( td, name, sc );802 return buildSymbolic( td, name, scs ); 803 803 } else { 804 return (new ObjectDecl( name, sc , linkage, bitfieldWidth, typebuild( td ), init, attributes, isInline, isNoreturn))->set_asmName( asmName );804 return (new ObjectDecl( name, scs, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName ); 805 805 } // if 806 806 return nullptr; … … 820 820 break; 821 821 default: 822 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", DeclarationNode::NoStorageClass, nullptr, false, false, LinkageSpec::Cforall, nullptr ) ) );822 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", DeclarationNode::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 823 823 } // switch 824 824 } else { 825 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );825 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 826 826 } // if 827 827 return ft; … … 846 846 for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = dynamic_cast< DeclarationNode * >( decl->get_next() ) ) { 847 847 // scan ALL parameter names for each declaration name to check for duplicates 848 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode * >( param->get_next() ) ) {848 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode * >( param->get_next() ) ) { 849 849 if ( *decl->name == *param->name ) { 850 850 // type set => parameter name already transformed by a declaration names so there is a duplicate … … 867 867 // rtb( a, b, c ) const char * b; {} => int rtn( int a, const char * b, int c ) {} 868 868 869 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode * >( param->get_next() ) ) {869 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode * >( param->get_next() ) ) { 870 870 if ( ! param->type ) { // generate type int for empty parameter type 871 871 param->type = new TypeData( TypeData::Basic ); -
src/Parser/TypeData.h
r87c3bef rbe8bd88 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 23 17:14:46201713 // Update Count : 1 5812 // Last Modified On : Tue Mar 7 08:03:53 2017 13 // Update Count : 173 14 14 // 15 15 … … 76 76 DeclarationNode::Length length = DeclarationNode::NoLength; 77 77 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 78 typedef std::bitset< DeclarationNode::No Qualifier >Qualifiers;79 Qualifiers qualifiers;78 typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers; 79 TypeQualifiers typeQualifiers; 80 80 DeclarationNode * forall; 81 81 … … 107 107 ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes ); 108 108 ReferenceToType * buildAggInst( const TypeData * ); 109 NamedTypeDecl * buildSymbolic( const TypeData *, const std::string &name, DeclarationNode::StorageClass sc );110 109 TypeDecl * buildVariable( const TypeData * ); 111 110 EnumDecl * buildEnum( const TypeData *, std::list< Attribute * > ); … … 113 112 TupleType * buildTuple( const TypeData * ); 114 113 TypeofType * buildTypeof( const TypeData * ); 115 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClass , Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );114 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 116 115 FunctionType * buildFunction( const TypeData * ); 117 116 void buildKRFunction( const TypeData::Function_t & function ); -
src/Parser/lex.ll
r87c3bef rbe8bd88 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Tue Nov 29 11:32:00 201613 * Update Count : 50 112 * Last Modified On : Fri Mar 3 22:18:00 2017 13 * Update Count : 502 14 14 */ 15 15 … … 235 235 long { KEYWORD_RETURN(LONG); } 236 236 lvalue { KEYWORD_RETURN(LVALUE); } // CFA 237 mutex { KEYWORD_RETURN(MUTEX); } // CFA 237 238 _Noreturn { KEYWORD_RETURN(NORETURN); } // C11 238 239 __builtin_offsetof { KEYWORD_RETURN(OFFSETOF); } // GCC -
src/Parser/parser.yy
r87c3bef rbe8bd88 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 28 09:58:10201713 // Update Count : 22 0812 // Last Modified On : Sun Mar 5 15:48:24 2017 13 // Update Count : 2227 14 14 // 15 15 … … 91 91 // keywords 92 92 %token TYPEDEF 93 %token AUTO EXTERN REGISTER STATIC 94 %token INLINE // C99 95 %token FORTRAN // C99, extension ISO/IEC 9899:1999 Section J.5.9(1) 93 %token EXTERN STATIC AUTO REGISTER 94 %token THREADLOCAL // C11 95 %token INLINE FORTRAN // C99, extension ISO/IEC 9899:1999 Section J.5.9(1) 96 %token NORETURN // C11 96 97 %token CONST VOLATILE 97 98 %token RESTRICT // C99 98 %token FORALL LVALUE // CFA 99 %token ATOMIC // C11 100 %token FORALL LVALUE MUTEX // CFA 99 101 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 100 102 %token VALIST // GCC … … 102 104 %token TYPEOF LABEL // GCC 103 105 %token ENUM STRUCT UNION 104 %token OTYPE FTYPE DTYPE TTYPE TRAIT 106 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA 105 107 %token SIZEOF OFFSETOF 106 108 %token ATTRIBUTE EXTENSION // GCC … … 108 110 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT // CFA 109 111 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 110 %token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATICASSERT THREADLOCAL// C11112 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 111 113 112 114 // names and constants: lexer differentiates between identifier and typedef names … … 1400 1402 type_qualifier_name: 1401 1403 CONST 1402 { $$ = DeclarationNode::new Qualifier( DeclarationNode::Const ); }1404 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Const ); } 1403 1405 | RESTRICT 1404 { $$ = DeclarationNode::new Qualifier( DeclarationNode::Restrict ); }1406 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Restrict ); } 1405 1407 | VOLATILE 1406 { $$ = DeclarationNode::new Qualifier( DeclarationNode::Volatile ); }1408 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Volatile ); } 1407 1409 | LVALUE // CFA 1408 { $$ = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 1410 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Lvalue ); } 1411 | MUTEX 1412 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Mutex ); } 1409 1413 | ATOMIC 1410 { $$ = DeclarationNode::new Qualifier( DeclarationNode::Atomic ); }1414 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Atomic ); } 1411 1415 | FORALL '(' 1412 1416 { … … 1448 1452 | REGISTER 1449 1453 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 1450 | INLINE // C991451 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Inline ); }1452 { $$ = new DeclarationNode; $$->isInline = true; }1453 | FORTRAN // C991454 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }1455 | NORETURN // C111456 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Noreturn ); }1457 { $$ = new DeclarationNode; $$->isNoreturn = true; }1458 1454 | THREADLOCAL // C11 1459 1455 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 1456 // Put function specifiers here to simplify parsing rules, but separate them semantically. 1457 | INLINE // C99 1458 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); } 1459 | FORTRAN // C99 1460 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); } 1461 | NORETURN // C11 1462 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); } 1460 1463 ; 1461 1464 … … 2033 2036 { $$ = $3->addQualifiers( $1 ); } 2034 2037 | type_declaring_list ',' type_declarator 2035 { $$ = $1->appendList( $3->copyS torageClasses( $1 ) ); }2038 { $$ = $1->appendList( $3->copySpecifiers( $1 ) ); } 2036 2039 ; 2037 2040 -
src/ResolvExpr/Unify.cc
r87c3bef rbe8bd88 10 10 // Created On : Sun May 17 12:27:10 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:37:05 201613 // Update Count : 3 712 // Last Modified On : Mon Mar 6 23:37:38 2017 13 // Update Count : 39 14 14 // 15 15 … … 541 541 flatten( dcl->get_type(), back_inserter( types ) ); 542 542 for ( Type * t : types ) { 543 dst.push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::C, nullptr, t, nullptr ) );543 dst.push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) ); 544 544 } 545 545 delete dcl; -
src/SymTab/Autogen.cc
r87c3bef rbe8bd88 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 15:02:50201713 // Update Count : 1312 // Last Modified On : Tue Mar 7 07:42:44 2017 13 // Update Count : 51 14 14 // 15 15 … … 125 125 FunctionType * genDefaultType( Type * paramType ) { 126 126 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 127 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr );127 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr ); 128 128 ftype->get_parameters().push_back( dstParam ); 129 129 … … 134 134 FunctionType * genCopyType( Type * paramType ) { 135 135 FunctionType *ftype = genDefaultType( paramType ); 136 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );136 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 137 137 ftype->get_parameters().push_back( srcParam ); 138 138 return ftype; … … 142 142 FunctionType * genAssignType( Type * paramType ) { 143 143 FunctionType *ftype = genCopyType( paramType ); 144 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );144 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 145 145 ftype->get_returnVals().push_back( returnVal ); 146 146 return ftype; … … 161 161 // Routines at global scope marked "static" to prevent multiple definitions in separate translation units 162 162 // because each unit generates copies of the default routines for each aggregate. 163 DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 163 // DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ); 164 165 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 165 FunctionDecl * decl = new FunctionDecl( fname, sc, spec, ftype, new CompoundStmt( noLabels ), true, false ); 166 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ), 167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ); 166 168 decl->fixUniqueId(); 167 169 return decl; … … 458 460 continue; 459 461 } 460 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );462 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) ); 461 463 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 462 464 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout ); … … 538 540 for ( Declaration * member : aggregateDecl->get_members() ) { 539 541 if ( DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member ) ) { 540 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 );542 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 ); 541 543 542 544 FunctionType * memCtorType = ctorType->clone(); … … 603 605 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 604 606 typeInst->set_baseType( typeDecl ); 605 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr );606 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr );607 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr ); 608 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr ); 607 609 608 610 std::list< Statement * > stmts; … … 616 618 } // if 617 619 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 618 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );620 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, typeInst, 0 ) ); 619 621 type->get_parameters().push_back( dst ); 620 622 type->get_parameters().push_back( src ); … … 715 717 if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) { 716 718 if ( ! done.count( ty->get_baseType() ) ) { 717 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode:: NoStorageClass, nullptr, TypeDecl::Any );719 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::StorageClasses(), nullptr, TypeDecl::Any ); 718 720 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 719 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genAssignType( inst ), nullptr, true, false ) ); 720 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr, true, false ) ); 721 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genCopyType( inst ), nullptr, true, false ) ); 722 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr, true, false ) ); 721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 723 729 typeParams.push_back( newDecl ); 724 730 done.insert( ty->get_baseType() ); -
src/SymTab/Autogen.h
r87c3bef rbe8bd88 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 1 16:31:00201713 // Update Count : 212 // Last Modified On : Mon Mar 6 23:33:01 2017 13 // Update Count : 4 14 14 // 15 15 … … 102 102 } 103 103 104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) ); 105 105 106 106 UntypedExpr *cond = new UntypedExpr( cmp ); -
src/SymTab/FixFunction.cc
r87c3bef rbe8bd88 10 10 // Created On : Sun May 17 16:19:49 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:31:10 201613 // Update Count : 312 // Last Modified On : Mon Mar 6 23:36:59 2017 13 // Update Count : 6 14 14 // 15 15 … … 21 21 22 22 namespace SymTab { 23 FixFunction::FixFunction() : isVoid( false ) { 24 } 23 FixFunction::FixFunction() : isVoid( false ) {} 25 24 26 25 DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) { 27 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass (), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() );26 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() ); 28 27 functionDecl->get_attributes().clear(); 29 28 delete functionDecl; -
src/SymTab/Indexer.cc
r87c3bef rbe8bd88 10 10 // Created On : Sun May 17 21:37:33 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 14:59:19201713 // Update Count : 1 312 // Last Modified On : Tue Mar 7 07:45:32 2017 13 // Update Count : 16 14 14 // 15 15 … … 738 738 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added ); 739 739 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing ); 740 if ( newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern) {740 if ( ! newobj->get_storageClasses()[ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ] ) { 741 741 throw SemanticError( "duplicate object definition for ", added ); 742 742 } // if -
src/SymTab/Validate.cc
r87c3bef rbe8bd88 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 23 21:33:55201713 // Update Count : 3 1812 // Last Modified On : Tue Mar 7 07:51:36 2017 13 // Update Count : 349 14 14 // 15 15 … … 97 97 class ReturnTypeFixer final : public Visitor { 98 98 public: 99 100 99 typedef Visitor Parent; 101 100 using Parent::visit; … … 104 103 105 104 virtual void visit( FunctionDecl * functionDecl ); 106 107 105 virtual void visit( FunctionType * ftype ); 108 106 }; … … 161 159 private: 162 160 virtual void visit( FunctionDecl * functionDecl ); 163 164 161 virtual void visit( ReturnStmt * returnStmt ); 165 162 … … 211 208 212 209 class CompoundLiteral final : public GenPoly::DeclMutator { 213 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;210 DeclarationNode::StorageClasses storageClasses; 214 211 215 212 using GenPoly::DeclMutator::mutate; … … 660 657 // Note, qualifiers on the typedef are superfluous for the forward declaration. 661 658 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) { 662 return aggDecl->get_baseStruct() ? Mutator::mutate( aggDecl->get_baseStruct() ) :new StructDecl( aggDecl->get_name() );659 return new StructDecl( aggDecl->get_name() ); 663 660 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) { 664 return aggDecl->get_baseUnion() ? Mutator::mutate( aggDecl->get_baseUnion() ) :new UnionDecl( aggDecl->get_name() );661 return new UnionDecl( aggDecl->get_name() ); 665 662 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( tyDecl->get_base() ) ) { 666 663 return new EnumDecl( enumDecl->get_name() ); … … 691 688 DeclarationWithType *ret = Mutator::mutate( objDecl ); 692 689 typedefNames.endScope(); 693 // is the type a function? 694 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { 690 691 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { // function type? 695 692 // replace the current object declaration with a function declaration 696 FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClass (), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn(), objDecl->get_attributes() );693 FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClasses(), ret->get_linkage(), funtype, 0, objDecl->get_attributes(), ret->get_funcSpec() ); 697 694 objDecl->get_attributes().clear(); 698 695 objDecl->set_type( nullptr ); 699 696 delete objDecl; 700 697 return newDecl; 701 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) {702 throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl );703 698 } // if 704 699 return ret; … … 759 754 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 760 755 } // if 761 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode:: NoStorageClass, type ) );756 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::StorageClasses(), type ) ); 762 757 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel ); 763 758 } // if … … 813 808 814 809 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) { 815 storage class = objectDecl->get_storageClass();810 storageClasses = objectDecl->get_storageClasses(); 816 811 DeclarationWithType * temp = Mutator::mutate( objectDecl ); 817 storageclass = DeclarationNode::NoStorageClass;818 812 return temp; 819 813 } … … 824 818 static UniqueName indexName( "_compLit" ); 825 819 826 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storage class, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );820 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() ); 827 821 compLitExpr->set_type( 0 ); 828 822 compLitExpr->set_initializer( 0 ); … … 863 857 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 864 858 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 865 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );859 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 866 860 deleteAll( retVals ); 867 861 retVals.clear(); -
src/SynTree/AggregateDecl.cc
r87c3bef rbe8bd88 10 10 // Created On : Sun May 17 23:56:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 6 15:31:23201713 // Update Count : 1 712 // Last Modified On : Tue Mar 7 07:31:47 2017 13 // Update Count : 19 14 14 // 15 15 … … 20 20 21 21 22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode:: NoStorageClass, LinkageSpec::Cforall ), body( false ), attributes( attributes ) {22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) { 23 23 } 24 24 -
src/SynTree/Declaration.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 9 14:28:05201713 // Update Count : 1612 // Last Modified On : Tue Mar 7 07:31:11 2017 13 // Update Count : 23 14 14 // 15 15 … … 27 27 static IdMapType idMap; 28 28 29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage )30 : name( name ), storageClass ( sc ), linkage( linkage ), isInline( false ), isNoreturn( false ), uniqueId( 0 ) {29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage ) 30 : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) { 31 31 } 32 32 33 33 Declaration::Declaration( const Declaration &other ) 34 : name( other.name ), storageClass ( other.storageClass ), linkage( other.linkage ), isInline( other.isInline ), isNoreturn( other.isNoreturn), uniqueId( other.uniqueId ) {34 : name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage ), uniqueId( other.uniqueId ) { 35 35 } 36 36 … … 66 66 67 67 68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode:: NoStorageClass, LinkageSpec::C ), stmt( stmt ) {68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode::StorageClasses(), LinkageSpec::C ), stmt( stmt ) { 69 69 } 70 70 -
src/SynTree/Declaration.h
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 14:53:35201713 // Update Count : 5712 // Last Modified On : Tue Mar 7 07:40:42 2017 13 // Update Count : 113 14 14 // 15 15 … … 28 28 class Declaration : public BaseSyntaxNode { 29 29 public: 30 Declaration( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage );30 Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage ); 31 31 Declaration( const Declaration &other ); 32 32 virtual ~Declaration(); … … 34 34 const std::string &get_name() const { return name; } 35 35 void set_name( std::string newValue ) { name = newValue; } 36 DeclarationNode::StorageClass get_storageClass() const { return storageClass; } 37 void set_storageClass( DeclarationNode::StorageClass newValue ) { storageClass = newValue; } 36 37 DeclarationNode::StorageClasses get_storageClasses() const { return storageClasses; } 38 38 39 LinkageSpec::Spec get_linkage() const { return linkage; } 39 40 void set_linkage( LinkageSpec::Spec newValue ) { linkage = newValue; } 40 bool get_isInline() const { return isInline; } 41 void set_isInline( bool newValue ) { isInline = newValue; } 42 bool get_isNoreturn() const { return isNoreturn; } 43 void set_isNoreturn( bool newValue ) { isNoreturn = newValue; } 41 44 42 UniqueId get_uniqueId() const { return uniqueId; } 43 45 44 bool get_extension() const { return extension; } 46 45 Declaration *set_extension( bool exten ) { extension = exten; return this; } … … 57 56 private: 58 57 std::string name; 59 DeclarationNode::StorageClass storageClass;58 DeclarationNode::StorageClasses storageClasses; 60 59 LinkageSpec::Spec linkage; 61 bool isInline, isNoreturn;62 60 UniqueId uniqueId; 63 61 bool extension = false; … … 66 64 class DeclarationWithType : public Declaration { 67 65 public: 68 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes );66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs ); 69 67 DeclarationWithType( const DeclarationWithType &other ); 70 68 virtual ~DeclarationWithType(); … … 83 81 std::list< Attribute * >& get_attributes() { return attributes; } 84 82 const std::list< Attribute * >& get_attributes() const { return attributes; } 83 84 DeclarationNode::FuncSpecifiers get_funcSpec() const { return fs; } 85 //void set_functionSpecifiers( DeclarationNode::FuncSpecifiers newValue ) { fs = newValue; } 85 86 86 87 virtual DeclarationWithType *clone() const = 0; … … 97 98 ConstantExpr *asmName; 98 99 std::list< Attribute * > attributes; 100 DeclarationNode::FuncSpecifiers fs; 99 101 }; 100 102 … … 102 104 typedef DeclarationWithType Parent; 103 105 public: 104 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes = std::list< Attribute * >(), bool isInline = false, bool isNoreturn = false ); 106 ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 107 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() ); 105 108 ObjectDecl( const ObjectDecl &other ); 106 109 virtual ~ObjectDecl(); … … 129 132 typedef DeclarationWithType Parent; 130 133 public: 131 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, const std::list< Attribute * > attributes = std::list< Attribute * >() ); 134 FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 135 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() ); 132 136 FunctionDecl( const FunctionDecl &other ); 133 137 virtual ~FunctionDecl(); … … 154 158 typedef Declaration Parent; 155 159 public: 156 NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type );160 NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type ); 157 161 NamedTypeDecl( const NamedTypeDecl &other ); 158 162 virtual ~NamedTypeDecl(); … … 189 193 }; 190 194 191 TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind );195 TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind ); 192 196 TypeDecl( const TypeDecl &other ); 193 197 … … 210 214 typedef NamedTypeDecl Parent; 211 215 public: 212 TypedefDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type ) : Parent( name, sc, type ) {}216 TypedefDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {} 213 217 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 214 218 -
src/SynTree/DeclarationWithType.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 13 14:49:43 201613 // Update Count : 712 // Last Modified On : Tue Mar 7 07:32:14 2017 13 // Update Count : 23 14 14 // 15 15 … … 19 19 #include "Common/utility.h" 20 20 21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes )22 : Declaration( name, sc , linkage ), asmName( nullptr ), attributes( attributes ) {21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs ) 22 : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) { 23 23 } 24 24 25 25 DeclarationWithType::DeclarationWithType( const DeclarationWithType &other ) 26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) {26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ), fs( other.fs ) { 27 27 cloneAll( other.attributes, attributes ); 28 28 asmName = maybeClone( other.asmName ); -
src/SynTree/FunctionDecl.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 15:01:52201713 // Update Count : 2312 // Last Modified On : Tue Mar 7 07:54:58 2017 13 // Update Count : 68 14 14 // 15 15 … … 26 26 extern bool translation_unit_nomain; 27 27 28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes ) 29 : Parent( name, sc, linkage, attributes ), type( type ), statements( statements ) { 30 set_isInline( isInline ); 31 set_isNoreturn( isNoreturn ); 32 // this is a brazen hack to force the function "main" to have Cforall linkage 33 // because we want to replace the main even if it is inside an extern 28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs ) 29 : Parent( name, scs, linkage, attributes, fs ), type( type ), statements( statements ) { 30 // hack forcing the function "main" to have Cforall linkage to replace main even if it is inside an extern 34 31 if ( name == "main" ) { 35 32 set_linkage( CodeGen::FixMain::mainLinkage() ); … … 38 35 39 36 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 40 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {37 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 41 38 } 42 39 … … 65 62 os << LinkageSpec::linkageName( get_linkage() ) << " "; 66 63 } // if 67 if ( get_isInline() ) {68 os << "inline ";69 } // if70 if ( get_isNoreturn() ) {71 os << "_Noreturn ";72 } // if73 64 74 65 printAll( get_attributes(), os, indent ); 75 66 76 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {77 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';78 } // if 67 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 68 DeclarationNode::print_FuncSpec( os, get_funcSpec() ); 69 79 70 if ( get_type() ) { 80 71 get_type()->print( os, indent ); … … 97 88 os << get_name() << ": "; 98 89 } // if 99 if ( get_isInline() ) {100 os << "inline ";101 } // if102 if ( get_isNoreturn() ) {103 os << "_Noreturn ";104 } // if105 90 106 91 // xxx - should printShort print attributes? 107 92 108 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {109 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';110 } // if 93 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 94 DeclarationNode::print_FuncSpec( os, get_funcSpec() ); 95 111 96 if ( get_type() ) { 112 97 get_type()->print( os, indent ); -
src/SynTree/NamedTypeDecl.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:13:55 201513 // Update Count : 312 // Last Modified On : Tue Mar 7 07:39:41 2017 13 // Update Count : 10 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *base )21 : Parent( name, sc , LinkageSpec::Cforall ), base( base ) {}20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *base ) 21 : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {} 22 22 23 23 NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other ) … … 39 39 os << get_name() << ": "; 40 40 } // if 41 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 42 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 43 } // if 41 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 44 42 os << typeString(); 45 43 if ( base ) { … … 63 61 os << get_name() << ": "; 64 62 } // if 65 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 66 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 67 } // if 63 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 68 64 os << typeString(); 69 65 if ( base ) { -
src/SynTree/ObjectDecl.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Oct 1 23:05:56 201613 // Update Count : 3212 // Last Modified On : Tue Mar 7 07:55:24 2017 13 // Update Count : 54 14 14 // 15 15 … … 22 22 #include "Statement.h" 23 23 24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn ) 25 : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 26 set_isInline( isInline ); 27 set_isNoreturn( isNoreturn ); 24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs ) 25 : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 28 26 } 29 27 … … 49 47 printAll( get_attributes(), os, indent ); 50 48 51 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 52 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 53 } // if 49 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 54 50 55 51 if ( get_type() ) { … … 85 81 // xxx - should printShort print attributes? 86 82 87 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 88 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 89 } // if 83 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 90 84 91 85 if ( get_type() ) { -
src/SynTree/Type.h
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 23 16:38:53201713 // Update Count : 3412 // Last Modified On : Wed Mar 1 09:11:45 2017 13 // Update Count : 41 14 14 // 15 15 … … 21 21 #include "SynTree.h" 22 22 #include "Visitor.h" 23 #include "Common/utility.h"24 23 25 24 class Type : public BaseSyntaxNode { … … 213 212 bool get_isVarArgs() const { return isVarArgs; } 214 213 void set_isVarArgs( bool newValue ) { isVarArgs = newValue; } 215 216 214 bool isTtype() const; 217 215 -
src/SynTree/TypeDecl.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:14:35 201513 // Update Count : 212 // Last Modified On : Tue Mar 7 07:39:09 2017 13 // Update Count : 4 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) { 21 21 } 22 22 -
src/Tuples/TupleAssignment.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 1 16:40:16201713 // Update Count : 312 // Last Modified On : Mon Mar 6 23:40:14 2017 13 // Update Count : 5 14 14 // 15 15 … … 240 240 ObjectDecl * TupleAssignSpotter::Matcher::newObject( UniqueName & namer, Expression * expr ) { 241 241 assert( expr->has_result() && ! expr->get_result()->isVoid() ); 242 ObjectDecl * ret = new ObjectDecl( namer.newName(), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );242 ObjectDecl * ret = new ObjectDecl( namer.newName(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 243 243 ConstructorInit * ctorInit = InitTweak::genCtorInit( ret ); 244 244 ret->set_init( ctorInit ); -
src/Tuples/TupleExpansion.cc
r87c3bef rbe8bd88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 1 16:40:40201713 // Update Count : 312 // Last Modified On : Tue Mar 7 07:43:56 2017 13 // Update Count : 12 14 14 // 15 15 … … 187 187 } 188 188 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 189 ObjectDecl * finished = new ObjectDecl( toString( "_unq_expr_finished_", id ), DeclarationNode:: NoStorageClass, LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) );189 ObjectDecl * finished = new ObjectDecl( toString( "_unq_expr_finished_", id ), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) ); 190 190 addDeclaration( finished ); 191 191 // (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N)) … … 221 221 decl->set_body( true ); 222 222 for ( size_t i = 0; i < tupleSize; ++i ) { 223 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", i), DeclarationNode::NoStorageClass, nullptr, TypeDecl::Any );224 decl->get_members().push_back( new ObjectDecl( toString("field_", i ), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) );223 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", i ), DeclarationNode::StorageClasses(), nullptr, TypeDecl::Any ); 224 decl->get_members().push_back( new ObjectDecl( toString("field_", i ), DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) ); 225 225 decl->get_parameters().push_back( tyParam ); 226 226 } 227 227 if ( tupleSize == 0 ) { 228 228 // empty structs are not standard C. Add a dummy field to empty tuples to silence warnings when a compound literal Tuple0 is created. 229 decl->get_members().push_back( new ObjectDecl( "dummy", DeclarationNode:: NoStorageClass, LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );229 decl->get_members().push_back( new ObjectDecl( "dummy", DeclarationNode::StorageClasses(), LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 230 230 } 231 231 typeMap[tupleSize] = decl; -
src/benchmark/Makefile.am
r87c3bef rbe8bd88 18 18 CFLAGS = 19 19 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 20 CC = @CFA_BINDIR@/ cfa20 CC = @CFA_BINDIR@/@CFA_NAME@ 21 21 22 22 noinst_PROGRAMS = bench ctxswitch-coroutine ctxswitch-thread -
src/benchmark/Makefile.in
r87c3bef rbe8bd88 94 94 AWK = @AWK@ 95 95 BACKEND_CC = @BACKEND_CC@ 96 CC = @CFA_BINDIR@/ cfa96 CC = @CFA_BINDIR@/@CFA_NAME@ 97 97 CCAS = @CCAS@ 98 98 CCASDEPMODE = @CCASDEPMODE@ … … 104 104 CFA_INCDIR = @CFA_INCDIR@ 105 105 CFA_LIBDIR = @CFA_LIBDIR@ 106 CFA_NAME = @CFA_NAME@ 106 107 CFA_PREFIX = @CFA_PREFIX@ 107 108 -
src/driver/Makefile.am
r87c3bef rbe8bd88 28 28 endif 29 29 30 bin_PROGRAMS = cfa30 noinst_PROGRAMS = cfa 31 31 cfa_SOURCES = cfa.cc 32 32 33 install-exec-hook: 34 @echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) cfa '$(CFA_BINDIR)/$(CFA_NAME)'"; \ 35 $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) cfa $(CFA_BINDIR)/$(CFA_NAME) || exit $$? 36 37 uninstall-hook: 38 @echo " ( cd '$(CFA_BINDIR)' && rm -f $(CFA_NAME) )"; \ 39 cd "$(CFA_BINDIR)" && rm -f $(CFA_NAME) 40 33 41 # put into lib for now 34 cc1libdir = ${ libdir}42 cc1libdir = ${CFA_LIBDIR} 35 43 cc1lib_PROGRAMS = cc1 36 44 cc1_SOURCES = cc1.cc 37 45 38 MAINTAINERCLEANFILES = @CFA_PREFIX@/bin/${bin_PROGRAMS}@CFA_PREFIX@/lib/${cc1lib_PROGRAMS}46 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} -
src/driver/Makefile.in
r87c3bef rbe8bd88 41 41 @BUILD_DEBUG_TRUE@am__append_2 = -DHAVE_LIBCFA_DEBUG 42 42 @BUILD_RELEASE_TRUE@am__append_3 = -DHAVE_LIBCFA_RELEASE 43 bin_PROGRAMS = cfa$(EXEEXT)43 noinst_PROGRAMS = cfa$(EXEEXT) 44 44 cc1lib_PROGRAMS = cc1$(EXEEXT) 45 45 subdir = src/driver … … 53 53 CONFIG_CLEAN_FILES = 54 54 CONFIG_CLEAN_VPATH_FILES = 55 am__installdirs = "$(DESTDIR)$( bindir)" "$(DESTDIR)$(cc1libdir)"56 PROGRAMS = $( bin_PROGRAMS) $(cc1lib_PROGRAMS)55 am__installdirs = "$(DESTDIR)$(cc1libdir)" 56 PROGRAMS = $(cc1lib_PROGRAMS) $(noinst_PROGRAMS) 57 57 am_cc1_OBJECTS = cc1.$(OBJEXT) 58 58 cc1_OBJECTS = $(am_cc1_OBJECTS) … … 106 106 CFA_INCDIR = @CFA_INCDIR@ 107 107 CFA_LIBDIR = @CFA_LIBDIR@ 108 CFA_NAME = @CFA_NAME@ 108 109 CFA_PREFIX = @CFA_PREFIX@ 109 110 CFLAGS = @CFLAGS@ … … 212 213 213 214 # put into lib for now 214 cc1libdir = ${ libdir}215 cc1libdir = ${CFA_LIBDIR} 215 216 cc1_SOURCES = cc1.cc 216 MAINTAINERCLEANFILES = @CFA_PREFIX@/bin/${bin_PROGRAMS}@CFA_PREFIX@/lib/${cc1lib_PROGRAMS}217 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME) @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} 217 218 all: all-am 218 219 … … 249 250 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 250 251 $(am__aclocal_m4_deps): 251 install-binPROGRAMS: $(bin_PROGRAMS)252 @$(NORMAL_INSTALL)253 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"254 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \255 for p in $$list; do echo "$$p $$p"; done | \256 sed 's/$(EXEEXT)$$//' | \257 while read p p1; do if test -f $$p; \258 then echo "$$p"; echo "$$p"; else :; fi; \259 done | \260 sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \261 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \262 sed 'N;N;N;s,\n, ,g' | \263 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \264 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \265 if ($$2 == $$4) files[d] = files[d] " " $$1; \266 else { print "f", $$3 "/" $$4, $$1; } } \267 END { for (d in files) print "f", d, files[d] }' | \268 while read type dir files; do \269 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \270 test -z "$$files" || { \271 echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \272 $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \273 } \274 ; done275 276 uninstall-binPROGRAMS:277 @$(NORMAL_UNINSTALL)278 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \279 files=`for p in $$list; do echo "$$p"; done | \280 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \281 -e 's/$$/$(EXEEXT)/' `; \282 test -n "$$list" || exit 0; \283 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \284 cd "$(DESTDIR)$(bindir)" && rm -f $$files285 286 clean-binPROGRAMS:287 -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)288 252 install-cc1libPROGRAMS: $(cc1lib_PROGRAMS) 289 253 @$(NORMAL_INSTALL) … … 323 287 clean-cc1libPROGRAMS: 324 288 -test -z "$(cc1lib_PROGRAMS)" || rm -f $(cc1lib_PROGRAMS) 289 290 clean-noinstPROGRAMS: 291 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) 325 292 cc1$(EXEEXT): $(cc1_OBJECTS) $(cc1_DEPENDENCIES) $(EXTRA_cc1_DEPENDENCIES) 326 293 @rm -f cc1$(EXEEXT) … … 439 406 all-am: Makefile $(PROGRAMS) 440 407 installdirs: 441 for dir in "$(DESTDIR)$( bindir)" "$(DESTDIR)$(cc1libdir)"; do \408 for dir in "$(DESTDIR)$(cc1libdir)"; do \ 442 409 test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 443 410 done … … 475 442 clean: clean-am 476 443 477 clean-am: clean- binPROGRAMS clean-cc1libPROGRAMS clean-generic\444 clean-am: clean-cc1libPROGRAMS clean-generic clean-noinstPROGRAMS \ 478 445 mostlyclean-am 479 446 … … 502 469 install-dvi-am: 503 470 504 install-exec-am: install-binPROGRAMS 505 471 install-exec-am: 472 @$(NORMAL_INSTALL) 473 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook 506 474 install-html: install-html-am 507 475 … … 541 509 ps-am: 542 510 543 uninstall-am: uninstall-binPROGRAMS uninstall-cc1libPROGRAMS 544 545 .MAKE: install-am install-strip 546 547 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ 548 clean-cc1libPROGRAMS clean-generic ctags distclean \ 549 distclean-compile distclean-generic distclean-tags distdir dvi \ 550 dvi-am html html-am info info-am install install-am \ 551 install-binPROGRAMS install-cc1libPROGRAMS install-data \ 552 install-data-am install-dvi install-dvi-am install-exec \ 553 install-exec-am install-html install-html-am install-info \ 511 uninstall-am: uninstall-cc1libPROGRAMS 512 @$(NORMAL_INSTALL) 513 $(MAKE) $(AM_MAKEFLAGS) uninstall-hook 514 .MAKE: install-am install-exec-am install-strip uninstall-am 515 516 .PHONY: CTAGS GTAGS all all-am check check-am clean \ 517 clean-cc1libPROGRAMS clean-generic clean-noinstPROGRAMS ctags \ 518 distclean distclean-compile distclean-generic distclean-tags \ 519 distdir dvi dvi-am html html-am info info-am install \ 520 install-am install-cc1libPROGRAMS install-data install-data-am \ 521 install-dvi install-dvi-am install-exec install-exec-am \ 522 install-exec-hook install-html install-html-am install-info \ 554 523 install-info-am install-man install-pdf install-pdf-am \ 555 524 install-ps install-ps-am install-strip installcheck \ … … 557 526 maintainer-clean-generic mostlyclean mostlyclean-compile \ 558 527 mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ 559 uninstall-am uninstall-binPROGRAMS uninstall-cc1libPROGRAMS 560 528 uninstall-am uninstall-cc1libPROGRAMS uninstall-hook 529 530 531 install-exec-hook: 532 @echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) cfa '$(CFA_BINDIR)/$(CFA_NAME)'"; \ 533 $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) cfa $(CFA_BINDIR)/$(CFA_NAME) || exit $$? 534 535 uninstall-hook: 536 @echo " ( cd '$(CFA_BINDIR)' && rm -f $(CFA_NAME) )"; \ 537 cd "$(CFA_BINDIR)" && rm -f $(CFA_NAME) 561 538 562 539 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/examples/Makefile.am
r87c3bef rbe8bd88 18 18 CFLAGS = 19 19 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 20 CC = @CFA_BINDIR@/ cfa20 CC = @CFA_BINDIR@/@CFA_NAME@ 21 21 22 22 noinst_PROGRAMS = fstream_test vector_test avl_test Bench # build but do not install -
src/examples/Makefile.in
r87c3bef rbe8bd88 105 105 AWK = @AWK@ 106 106 BACKEND_CC = @BACKEND_CC@ 107 CC = @CFA_BINDIR@/ cfa107 CC = @CFA_BINDIR@/@CFA_NAME@ 108 108 CCAS = @CCAS@ 109 109 CCASDEPMODE = @CCASDEPMODE@ … … 115 115 CFA_INCDIR = @CFA_INCDIR@ 116 116 CFA_LIBDIR = @CFA_LIBDIR@ 117 CFA_NAME = @CFA_NAME@ 117 118 CFA_PREFIX = @CFA_PREFIX@ 118 119 -
src/libcfa/Makefile.am
r87c3bef rbe8bd88 18 18 AUTOMAKE_OPTIONS = subdir-objects 19 19 20 libdir = ${CFA_LIBDIR} 20 21 lib_LIBRARIES = 21 22 … … 67 68 ${libobjs} : ${abs_top_srcdir}/src/driver/cfa-cpp ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator 68 69 69 70 70 libcfa_a_SOURCES = ${libsrc} 71 71 libcfa_a_CFLAGS = -nodebug -O2 … … 75 75 stdhdr = ${shell echo stdhdr/*} 76 76 77 cfa_includedir = $( includedir)/cfa77 cfa_includedir = $(CFA_INCDIR) 78 78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h 79 79 … … 81 81 82 82 maintainer-clean-local: 83 -rm -rf ${ includedir}/*83 -rm -rf ${CFA_INCDIR} ${CFA_LIBDIR} -
src/libcfa/Makefile.in
r87c3bef rbe8bd88 201 201 CFA_INCDIR = @CFA_INCDIR@ 202 202 CFA_LIBDIR = @CFA_LIBDIR@ 203 CFA_NAME = @CFA_NAME@ 203 204 CFA_PREFIX = @CFA_PREFIX@ 204 205 CFLAGS = -quiet -no-include-stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS} … … 281 282 infodir = @infodir@ 282 283 install_sh = @install_sh@ 283 libdir = @libdir@284 libdir = ${CFA_LIBDIR} 284 285 libexecdir = @libexecdir@ 285 286 localedir = @localedir@ … … 315 316 libcfa_d_a_CFLAGS = -debug -O0 316 317 stdhdr = ${shell echo stdhdr/*} 317 cfa_includedir = $( includedir)/cfa318 cfa_includedir = $(CFA_INCDIR) 318 319 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h 319 320 CLEANFILES = libcfa-prelude.c … … 1160 1161 1161 1162 maintainer-clean-local: 1162 -rm -rf ${ includedir}/*1163 -rm -rf ${CFA_INCDIR} ${CFA_LIBDIR} 1163 1164 1164 1165 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/libcfa/iostream
r87c3bef rbe8bd88 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 24 21:09:09201713 // Update Count : 9 412 // Last Modified On : Mon Mar 6 20:51:35 2017 13 // Update Count : 98 14 14 // 15 15 … … 68 68 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * ); 69 69 70 // tuples 71 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) ostype * ?|?( ostype * os, T arg, Params rest ); 72 73 // manipulators 70 74 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) ); 71 // manipulators72 75 forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * ); 73 76 forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * ); -
src/libcfa/iostream.c
r87c3bef rbe8bd88 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 24 21:09:59201713 // Update Count : 3 0712 // Last Modified On : Mon Mar 6 20:52:02 2017 13 // Update Count : 313 14 14 // 15 15 … … 155 155 enum { Open = 1, Close, OpenClose }; 156 156 static const unsigned char mask[256] = { 157 // opening delimiters 157 // opening delimiters, no space after 158 158 ['('] : Open, ['['] : Open, ['{'] : Open, 159 ['$'] : Open, [ (unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,159 ['$'] : Open, ['='] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, 160 160 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 161 // closing delimiters 161 // closing delimiters, no space before 162 162 [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close, 163 163 [')'] : Close, [']'] : Close, ['}'] : Close, 164 164 ['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close, 165 // opening-closing delimiters 165 // opening-closing delimiters, no space before or after 166 166 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, 167 167 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace … … 198 198 199 199 200 // tuples 201 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) 202 ostype * ?|?( ostype * os, T arg, Params rest ) { 203 os | arg | ", "; 204 os | rest; 205 } // ?|? 206 207 208 // manipulators 200 209 forall( dtype ostype | ostream( ostype ) ) 201 210 ostype * ?|?( ostype * os, ostype * (* manip)( ostype * ) ) { -
src/libcfa/stdlib
r87c3bef rbe8bd88 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 24 21:07:16201713 // Update Count : 10 112 // Last Modified On : Sat Mar 4 22:03:54 2017 13 // Update Count : 102 14 14 // 15 15 -
src/libcfa/stdlib.c
r87c3bef rbe8bd88 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 24 21:08:11201713 // Update Count : 17 112 // Last Modified On : Sat Mar 4 22:02:22 2017 13 // Update Count : 172 14 14 // 15 15 -
src/prelude/Makefile.am
r87c3bef rbe8bd88 19 19 20 20 # put into lib for now 21 cfalibdir = ${ libdir}21 cfalibdir = ${CFA_LIBDIR} 22 22 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c 23 23 noinst_DATA = ../libcfa/libcfa-prelude.c -
src/prelude/Makefile.in
r87c3bef rbe8bd88 105 105 CFA_INCDIR = @CFA_INCDIR@ 106 106 CFA_LIBDIR = @CFA_LIBDIR@ 107 CFA_NAME = @CFA_NAME@ 107 108 CFA_PREFIX = @CFA_PREFIX@ 108 109 CFLAGS = @CFLAGS@ … … 209 210 210 211 # put into lib for now 211 cfalibdir = ${ libdir}212 cfalibdir = ${CFA_LIBDIR} 212 213 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c 213 214 noinst_DATA = ../libcfa/libcfa-prelude.c -
src/tests/.expect/tupleAssign.txt
r87c3bef rbe8bd88 1 u=5 v=6 x=10 y=11 z=[100, 200] 1 2 u=5 v=6 x=10 y=11 z=[100, 200] 2 3 u=11 v=10 x=11 y=10 z=[11, 10] 4 u=11 v=10 x=11 y=10 z=[11, 10] 5 u=10 v=11 z=[10, 11] 3 6 u=10 v=11 z=[10, 11] 4 7 u=123 v=456 z=[111, 222] 5 d=-2153.12 i=-2153 c=-105 t=[-2153, -2153.12, -2153] 6 d=-2153.12 i=-2153 c=-105 t=[-2153, -2153.12, -2153] 8 u=123 v=456 z=[111, 222] 9 d=94.12 i=94 c=^ t=[94, 94.12, 94] 10 d=94.12 i=94 c=^ t=[94, 94.12, 94] 11 d=-94.12 i=-94 c=¢ t=[-94, -94.12, -94] 12 d=-94.12 i=-94 c=¢ t=[-94, -94.12, -94] -
src/tests/Makefile.am
r87c3bef rbe8bd88 30 30 EXTRA_FLAGS = 31 31 CFLAGS = -g -Wall -Wno-unused-function @CFA_FLAGS@ ${EXTRA_FLAGS} 32 CC = @CFA_BINDIR@/ cfa32 CC = @CFA_BINDIR@/@CFA_NAME@ 33 33 34 34 .PHONY : list -
src/tests/Makefile.in
r87c3bef rbe8bd88 113 113 AWK = @AWK@ 114 114 BACKEND_CC = @BACKEND_CC@ 115 CC = @CFA_BINDIR@/ cfa115 CC = @CFA_BINDIR@/@CFA_NAME@ 116 116 CCAS = @CCAS@ 117 117 CCASDEPMODE = @CCASDEPMODE@ … … 123 123 CFA_INCDIR = @CFA_INCDIR@ 124 124 CFA_LIBDIR = @CFA_LIBDIR@ 125 CFA_NAME = @CFA_NAME@ 125 126 CFA_PREFIX = @CFA_PREFIX@ 126 127 CFLAGS = -g -Wall -Wno-unused-function @CFA_FLAGS@ ${EXTRA_FLAGS} -
src/tests/tupleAssign.c
r87c3bef rbe8bd88 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Nov 15 17:24:32 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Nov 15 17:27:28 201613 // Update Count : 3 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 21:23:58 2017 13 // Update Count : 34 14 14 // 15 16 #include <fstream> 15 17 16 18 int main() { … … 21 23 22 24 // swap x, y and store the new [x, y] in [u, v] and in z; 23 printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z); 25 printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z ); 26 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl; 24 27 z = [u, v] = [x, y] = [y, x]; 25 printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z); 28 printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z ); 29 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl; 26 30 27 31 // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v 28 32 [v, z, u] = [z, u, v]; 29 printf("u=%d v=%d z=[%d, %d]\n", u, v, z); 33 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 34 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl; 30 35 31 36 // multiple assignment with tuple expression on right 32 37 z = [111, 222]; 33 38 [u, v] = [123, 456]; 34 printf("u=%d v=%d z=[%d, %d]\n", u, v, z); 39 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 40 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl; 35 41 } 36 37 42 { 38 43 // test mass assignment … … 48 53 // no conversion from X to integral types, so this serves as a santiy 49 54 // check that as long as this compiles, ?=?(_, x) is not generated. 50 [t, x, d, i, c, x] = (double)-2153.12; 51 printf("d=%lg i=%d c=%d t=[%d, %lg, %d]\n", d, i, (int)c, t); 52 [x, c, i, d, x, t] = (double)-2153.12; 53 printf("d=%lg i=%d c=%d t=[%d, %lg, %d]\n", d, i, (int)c, t); 55 [t, x, d, i, c, x] = (double)94.12; 56 printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, (int)c, t ); 57 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl; 58 [x, c, i, d, x, t] = (double)-94.12; 59 printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, c, t ); 60 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl; 54 61 } 55 62 }
Note: See TracChangeset
for help on using the changeset viewer.