Changes in / [be8bd88:87c3bef]
- Files:
-
- 5 added
- 57 edited
-
.gitignore (modified) (2 diffs)
-
Makefile.in (modified) (1 diff)
-
configure (modified) (6 diffs)
-
configure.ac (modified) (3 diffs)
-
src/CodeGen/CodeGenerator.cc (modified) (4 diffs)
-
src/CodeGen/CodeGenerator.h (modified) (2 diffs)
-
src/CodeGen/FixNames.cc (modified) (3 diffs)
-
src/GenPoly/Box.cc (modified) (14 diffs)
-
src/GenPoly/Specialize.cc (modified) (2 diffs)
-
src/InitTweak/FixGlobalInit.cc (modified) (2 diffs)
-
src/InitTweak/FixInit.cc (modified) (11 diffs)
-
src/InitTweak/GenInit.cc (modified) (4 diffs)
-
src/InitTweak/InitTweak.cc (modified) (1 diff)
-
src/Makefile.am (modified) (1 diff)
-
src/Makefile.in (modified) (2 diffs)
-
src/Parser/DeclarationNode.cc (modified) (29 diffs)
-
src/Parser/ExpressionNode.cc (modified) (3 diffs)
-
src/Parser/ParseNode.h (modified) (12 diffs)
-
src/Parser/TypeData.cc (modified) (17 diffs)
-
src/Parser/TypeData.h (modified) (4 diffs)
-
src/Parser/lex.cc (added)
-
src/Parser/lex.ll (modified) (2 diffs)
-
src/Parser/parser.cc (added)
-
src/Parser/parser.h (added)
-
src/Parser/parser.yy (modified) (7 diffs)
-
src/ResolvExpr/Unify.cc (modified) (2 diffs)
-
src/SymTab/Autogen.cc (modified) (10 diffs)
-
src/SymTab/Autogen.h (modified) (2 diffs)
-
src/SymTab/FixFunction.cc (modified) (2 diffs)
-
src/SymTab/Indexer.cc (modified) (2 diffs)
-
src/SymTab/Validate.cc (modified) (11 diffs)
-
src/SynTree/AggregateDecl.cc (modified) (2 diffs)
-
src/SynTree/Declaration.cc (modified) (3 diffs)
-
src/SynTree/Declaration.h (modified) (12 diffs)
-
src/SynTree/DeclarationWithType.cc (modified) (2 diffs)
-
src/SynTree/FunctionDecl.cc (modified) (5 diffs)
-
src/SynTree/NamedTypeDecl.cc (modified) (4 diffs)
-
src/SynTree/ObjectDecl.cc (modified) (4 diffs)
-
src/SynTree/Type.h (modified) (3 diffs)
-
src/SynTree/TypeDecl.cc (modified) (2 diffs)
-
src/Tuples/TupleAssignment.cc (modified) (2 diffs)
-
src/Tuples/TupleExpansion.cc (modified) (3 diffs)
-
src/benchmark/Makefile.am (modified) (1 diff)
-
src/benchmark/Makefile.in (modified) (2 diffs)
-
src/driver/Makefile.am (modified) (1 diff)
-
src/driver/Makefile.in (modified) (11 diffs)
-
src/examples/Makefile.am (modified) (1 diff)
-
src/examples/Makefile.in (modified) (2 diffs)
-
src/examples/rational.cc (added)
-
src/libcfa/Makefile.am (modified) (4 diffs)
-
src/libcfa/Makefile.in (modified) (4 diffs)
-
src/libcfa/iostream (modified) (2 diffs)
-
src/libcfa/iostream.c (modified) (3 diffs)
-
src/libcfa/stdlib (modified) (1 diff)
-
src/libcfa/stdlib.c (modified) (1 diff)
-
src/prelude/Makefile.am (modified) (1 diff)
-
src/prelude/Makefile.in (modified) (2 diffs)
-
src/prelude/builtins.c (added)
-
src/tests/.expect/tupleAssign.txt (modified) (1 diff)
-
src/tests/Makefile.am (modified) (1 diff)
-
src/tests/Makefile.in (modified) (2 diffs)
-
src/tests/tupleAssign.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
rbe8bd88 r87c3bef 30 30 31 31 src/prelude/builtins.cf 32 src/prelude/builtins.c33 32 src/prelude/extras.cf 34 33 src/prelude/bootloader.c … … 37 36 # generated by bison and lex from cfa.yy and lex.ll, respectively 38 37 src/Parser/parser.output 39 src/Parser/lex.cc40 src/Parser/parser.cc41 src/Parser/parser.h42 38 43 39 # generated by xfig for user manual -
Makefile.in
rbe8bd88 r87c3bef 135 135 CFA_INCDIR = @CFA_INCDIR@ 136 136 CFA_LIBDIR = @CFA_LIBDIR@ 137 CFA_NAME = @CFA_NAME@138 137 CFA_PREFIX = @CFA_PREFIX@ 139 138 CFLAGS = @CFLAGS@ -
configure
rbe8bd88 r87c3bef 668 668 CFA_BACKEND_CC 669 669 BACKEND_CC 670 CFA_NAME671 670 MAINT 672 671 MAINTAINER_MODE_FALSE … … 742 741 enable_silent_rules 743 742 enable_maintainer_mode 744 with_cfa_name745 743 with_backend_compiler 746 744 enable_target_release … … 1399 1397 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 1400 1398 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 1401 --with-cfa-name=NAME NAME too which cfa will be installed1402 1399 --with-backend-compiler=PROGRAM PROGRAM that performs the final code compilation (must be gcc-compatible) 1403 1400 … … 3004 3001 # may require auto* software to be installed 3005 3002 3006 # Allow program name tansformation3007 # will fille program_transform_name with appropriate sed regex3008 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 characters3011 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 compilation3017 if ! test "${cc1_name}" = "cc1"; then3018 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" 53021 fi3022 #We could support transforming cfa-cpp but since it is located in a unique subfolder we don't need to3023 if ! test "${cpp_name}" = "cfa-cpp"; then3024 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" 53027 fi3028 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=$withval3033 else3034 cfa_name="cfa"3035 fi3036 3037 3038 #Define the new name of the installed command3039 CFA_NAME=${cfa_name}3040 3041 3042 3003 rm -f version 3043 3004 echo ${PACKAGE_VERSION} > version # file containing version number for other tools … … 3277 3238 3278 3239 if test "$includedir" = '${prefix}/include'; then 3279 cfa_incdir="${cfa_prefix}/include/ ${cfa_name}"3240 cfa_incdir="${cfa_prefix}/include/cfa" 3280 3241 else 3281 3242 cfa_incdir=${includedir} … … 3303 3264 3304 3265 if test "$libdir" = '${exec_prefix}/lib'; then 3305 cfa_libdir= "${cfa_prefix}/lib/${cfa_name}"3266 cfa_libdir=${cfa_prefix}/lib 3306 3267 else 3307 3268 cfa_libdir=${libdir} -
configure.ac
rbe8bd88 r87c3bef 17 17 AM_INIT_AUTOMAKE 18 18 AM_MAINTAINER_MODE(enable) # may require auto* software to be installed 19 20 # Allow program name tansformation21 # will fill program_transform_name with appropriate sed regex22 AC_ARG_PROGRAM23 24 #Trasforming cc1 will break compilation25 if ! test "${program_transform_name}" = ""; then26 AC_MSG_ERROR([Program transform not supported.27 Use --with-cfa-name='[[Desired name here]]' instead])28 fi29 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 command35 AC_SUBST(CFA_NAME, ${cfa_name})36 19 37 20 rm -f version … … 146 129 147 130 if test "$includedir" = '${prefix}/include'; then 148 cfa_incdir="${cfa_prefix}/include/ ${cfa_name}"131 cfa_incdir="${cfa_prefix}/include/cfa" 149 132 else 150 133 cfa_incdir=${includedir} … … 162 145 163 146 if test "$libdir" = '${exec_prefix}/lib'; then 164 cfa_libdir= "${cfa_prefix}/lib/${cfa_name}"147 cfa_libdir=${cfa_prefix}/lib 165 148 else 166 149 cfa_libdir=${libdir} -
src/CodeGen/CodeGenerator.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 5 17:13:33201713 // Update Count : 4 7512 // Last Modified On : Thu Feb 16 14:56:29 2017 13 // Update Count : 418 14 14 // 15 15 … … 134 134 135 135 handleStorageClass( functionDecl ); 136 DeclarationNode::print_FuncSpec( output, functionDecl->get_funcSpec() ); 137 136 if ( functionDecl->get_isInline() ) { 137 output << "inline "; 138 } // if 139 if ( functionDecl->get_isNoreturn() ) { 140 output << "_Noreturn "; 141 } // if 138 142 output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), pretty ); 139 143 … … 831 835 } 832 836 837 833 838 void CodeGenerator::visit( ReturnStmt * returnStmt ) { 834 839 output << "return "; … … 894 899 } 895 900 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 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 } 901 931 902 932 std::string genName( DeclarationWithType * decl ) { -
src/CodeGen/CodeGenerator.h
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 1 16:20:04201713 // Update Count : 5012 // Last Modified On : Thu Feb 9 15:06:21 2017 13 // Update Count : 49 14 14 // 15 15 … … 123 123 124 124 void printDesignators( std::list< Expression * > & ); 125 void handleStorageClass( Declaration WithType*decl );125 void handleStorageClass( Declaration *decl ); 126 126 void handleAggregate( AggregateDecl *aggDecl ); 127 127 void handleTypedef( NamedTypeDecl *namedType ); -
src/CodeGen/FixNames.cc
rbe8bd88 r87c3bef 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Mar 6 23:32:08 201713 // Update Count : 1 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Apr 11 15:38:10 2016 13 // Update Count : 1 14 14 // 15 15 … … 39 39 std::string mangle_main() { 40 40 FunctionType* main_type; 41 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 42 main_type = new FunctionType( Type::Qualifiers(), true ), nullptr ) 43 }; 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 ) }; 44 48 main_type->get_returnVals().push_back( 45 new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )49 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 46 50 ); 47 51 48 auto && name = SymTab::Mangler::mangle( mainDecl.get() );52 auto&& name = SymTab::Mangler::mangle( mainDecl.get() ); 49 53 // std::cerr << name << std::endl; 50 54 return name; … … 52 56 std::string mangle_main_args() { 53 57 FunctionType* main_type; 54 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 55 main_type = new FunctionType( Type::Qualifiers(), false ), nullptr ) 56 }; 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 ) }; 57 65 main_type->get_returnVals().push_back( 58 new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )66 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 59 67 ); 60 68 61 69 mainDecl->get_functionType()->get_parameters().push_back( 62 new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )70 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 63 71 ); 64 72 65 73 mainDecl->get_functionType()->get_parameters().push_back( 66 new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0,74 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, 67 75 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 68 76 nullptr ) -
src/GenPoly/Box.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:45:59201713 // Update Count : 33012 // Last Modified On : Thu Feb 16 14:57:16 2017 13 // Update Count : 297 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:: 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 ) );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 ) ); 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( 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 ) ); 300 FunctionDecl *layoutDecl = new FunctionDecl( 301 layoutofName( typeDecl ), functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), true, false ); 304 302 layoutDecl->fixUniqueId(); 305 303 return layoutDecl; … … 368 366 PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType ); 369 367 370 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );368 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 ); 371 369 layoutFnType->get_parameters().push_back( sizeParam ); 372 ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );370 ObjectDecl *alignParam = new ObjectDecl( alignofName( structDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 373 371 layoutFnType->get_parameters().push_back( alignParam ); 374 ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );372 ObjectDecl *offsetParam = new ObjectDecl( offsetofName( structDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 375 373 layoutFnType->get_parameters().push_back( offsetParam ); 376 374 addOtypeParams( layoutFnType, otypeParams ); … … 429 427 PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType ); 430 428 431 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );429 ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 ); 432 430 layoutFnType->get_parameters().push_back( sizeParam ); 433 ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 );431 ObjectDecl *alignParam = new ObjectDecl( alignofName( unionDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType->clone(), 0 ); 434 432 layoutFnType->get_parameters().push_back( alignParam ); 435 433 addOtypeParams( layoutFnType, otypeParams ); … … 537 535 if ( adapters.find( mangleName ) == adapters.end() ) { 538 536 std::string adapterName = makeAdapterName( mangleName ); 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 ) ) );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 ) ) ); 540 538 } // if 541 539 } // for … … 656 654 657 655 ObjectDecl *Pass1::makeTemporary( Type *type ) { 658 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, type, 0 );656 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, type, 0 ); 659 657 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 660 658 return newObj; … … 765 763 Type * newType = param->clone(); 766 764 if ( env ) env->apply( newType ); 767 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, newType, 0 );765 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, newType, 0 ); 768 766 newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right??? 769 767 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); … … 831 829 makeRetParm( adapter ); 832 830 } // if 833 adapter->get_parameters().push_front( new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) );831 adapter->get_parameters().push_front( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ) ); 834 832 return adapter; 835 833 } … … 912 910 adapterBody->get_kids().push_back( bodyStmt ); 913 911 std::string adapterName = makeAdapterName( mangleName ); 914 return new FunctionDecl( adapterName, DeclarationNode:: StorageClasses(), LinkageSpec::C, adapterType, adapterBody);912 return new FunctionDecl( adapterName, DeclarationNode::NoStorageClass, LinkageSpec::C, adapterType, adapterBody, false, false ); 915 913 } 916 914 … … 1273 1271 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 1274 1272 std::string adapterName = makeAdapterName( mangleName ); 1275 paramList.push_front( new ObjectDecl( adapterName, DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );1273 paramList.push_front( new ObjectDecl( adapterName, DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) ); 1276 1274 adaptersDone.insert( adaptersDone.begin(), mangleName ); 1277 1275 } … … 1379 1377 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1380 1378 std::list< DeclarationWithType *> inferredParams; 1381 ObjectDecl newObj( "", DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );1382 ObjectDecl newPtr( "", DeclarationNode:: StorageClasses(), LinkageSpec::C, 0,1379 ObjectDecl newObj( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1380 ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, 1383 1381 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); 1384 1382 for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { … … 1634 1632 1635 1633 ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) { 1636 ObjectDecl *newObj = new ObjectDecl( name, DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, type, init );1634 ObjectDecl *newObj = new ObjectDecl( name, DeclarationNode::NoStorageClass, LinkageSpec::C, 0, type, init ); 1637 1635 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 1638 1636 return newObj; … … 1818 1816 memberDecl = origMember->clone(); 1819 1817 } else { 1820 memberDecl = new ObjectDecl( (*member)->get_name(), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, offsetType->clone(), 0 );1818 memberDecl = new ObjectDecl( (*member)->get_name(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, offsetType->clone(), 0 ); 1821 1819 } 1822 1820 inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) ); -
src/GenPoly/Specialize.cc
rbe8bd88 r87c3bef 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Mar 6 23:13:00 201713 // Update Count : 3011 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 28 15:17:45 2016 13 // Update Count : 24 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:: StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels ));157 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, newType, new CompoundStmt( noLabels ), false, false ); 158 158 thunkFunc->fixUniqueId(); 159 159 -
src/InitTweak/FixGlobalInit.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:14:19 201713 // Update Count : 1412 // Last Modified On : Wed Jun 29 22:33:15 2016 13 // Update Count : 4 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 orageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ));89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false ); 90 90 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::St orageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ));91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false ); 92 92 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 93 93 } -
src/InitTweak/FixInit.cc
rbe8bd88 r87c3bef 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:51:40201713 // Update Count : 5912 // Last Modified On : Thu Feb 16 14:58:43 2017 13 // Update Count : 35 14 14 // 15 15 … … 437 437 result = result->clone(); 438 438 env->apply( result ); 439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, result, 0 );439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, 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:: StorageClasses(), LinkageSpec::C, 0, result, 0 );485 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, 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:: StorageClasses(), LinkageSpec::C, 0, result, 0 );508 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, 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:: StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );540 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), DeclarationNode::NoStorageClass, 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 es()[ DeclarationNode::Static ]) {680 if ( objDecl->get_storageClass() == 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 orageClasses( DeclarationNode::StaticClass ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::Static, 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 orageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ));733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false ); 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 orageClasses( DeclarationNode::StaticClass ), 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::Static, 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_storageClasses()[ DeclarationNode::Static ]) {823 if ( objDecl->get_storageClass() != 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:: StorageClasses(), LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );1120 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr ); 1121 1121 addDeclaration( tmp ); 1122 1122 -
src/InitTweak/GenInit.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:51:38201713 // Update Count : 1 7912 // Last Modified On : Thu Feb 16 14:57:53 2017 13 // Update Count : 167 14 14 // 15 15 … … 120 120 void hoist( Type * type ); 121 121 122 DeclarationNode::StorageClass es storageClasses;122 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass; 123 123 bool inFunction = false; 124 124 }; … … 174 174 175 175 DeclarationWithType * HoistArrayDimension::mutate( ObjectDecl * objectDecl ) { 176 storage Classes = objectDecl->get_storageClasses();176 storageclass = objectDecl->get_storageClass(); 177 177 DeclarationWithType * temp = Parent::mutate( objectDecl ); 178 178 hoist( objectDecl->get_type() ); 179 storageclass = DeclarationNode::NoStorageClass; 179 180 return temp; 180 181 } … … 184 185 static UniqueName dimensionName( "_array_dim" ); 185 186 186 // C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension. 187 // C doesn't allow variable sized arrays at global scope or for static variables, 188 // so don't hoist dimension. 187 189 if ( ! inFunction ) return; 188 if ( storage Classes[ DeclarationNode::StaticClass]) return;190 if ( storageclass == DeclarationNode::Static ) return; 189 191 190 192 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { 191 193 if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist? 192 194 193 // don't need to hoist dimension if it's a constexpr - only need to if there's potential for side effects. 195 // don't need to hoist dimension if it's a constexpr - only need to if there's potential 196 // for side effects. 194 197 if ( isConstExpr( arrayType->get_dimension() ) ) return; 195 198 196 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storage Classes, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );199 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageclass, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) ); 197 200 arrayDimension->get_type()->set_isConst( true ); 198 201 -
src/InitTweak/InitTweak.cc
rbe8bd88 r87c3bef 260 260 (objDecl->get_init() == NULL || 261 261 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) 262 && ! objDecl->get_storageClasses()[ DeclarationNode::Extern ];262 && objDecl->get_storageClass() != DeclarationNode::Extern; 263 263 } 264 264 -
src/Makefile.am
rbe8bd88 r87c3bef 38 38 39 39 # put into lib for now 40 cfa_cpplibdir = ${ CFA_LIBDIR}40 cfa_cpplibdir = ${libdir} 41 41 cfa_cpplib_PROGRAMS = driver/cfa-cpp 42 42 driver_cfa_cpp_SOURCES = ${SRC} -
src/Makefile.in
rbe8bd88 r87c3bef 276 276 CFA_INCDIR = @CFA_INCDIR@ 277 277 CFA_LIBDIR = @CFA_LIBDIR@ 278 CFA_NAME = @CFA_NAME@279 278 CFA_PREFIX = @CFA_PREFIX@ 280 279 CFLAGS = @CFLAGS@ … … 437 436 438 437 # put into lib for now 439 cfa_cpplibdir = ${ CFA_LIBDIR}438 cfa_cpplibdir = ${libdir} 440 439 driver_cfa_cpp_SOURCES = ${SRC} 441 440 driver_cfa_cpp_LDADD = ${LEXLIB} -ldl # yywrap -
src/Parser/DeclarationNode.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 08:02:09201713 // Update Count : 93612 // Last Modified On : Thu Feb 23 22:21:06 2017 13 // Update Count : 775 14 14 // 15 15 … … 19 19 #include <algorithm> 20 20 #include <cassert> 21 #include <strings.h> // ffs22 21 23 22 #include "TypeData.h" … … 33 32 34 33 // These must remain in the same order as the corresponding DeclarationNode enumerations. 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" }; 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" }; 45 43 46 44 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 50 48 DeclarationNode::DeclarationNode() : 51 49 type( nullptr ), 50 storageClass( NoStorageClass ), 52 51 bitfieldWidth( nullptr ), 52 isInline( false ), 53 isNoreturn( false ), 53 54 hasEllipsis( false ), 54 55 linkage( ::linkage ), … … 89 90 90 91 newnode->type = maybeClone( type ); 91 newnode->storageClass es = storageClasses;92 newnode->storageClass = storageClass; 92 93 newnode->bitfieldWidth = maybeClone( bitfieldWidth ); 93 newnode->funcSpecs = funcSpecs; 94 newnode->isInline = isInline; 95 newnode->isNoreturn = isNoreturn; 94 96 newnode->enumeratorValue.reset( maybeClone( enumeratorValue.get() ) ); 95 97 newnode->hasEllipsis = hasEllipsis; … … 116 118 } 117 119 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 } // if124 } // for125 } // if126 } // print_StorageClass127 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 } // if134 } // for135 } // if136 } // print_FuncSpec137 138 120 void DeclarationNode::print( std::ostream &os, int indent ) const { 139 121 os << string( indent, ' ' ); … … 148 130 } // if 149 131 150 print_StorageClass( os, storageClasses );151 print_FuncSpec( os, funcSpecs );152 132 if ( storageClass != NoStorageClass ) os << DeclarationNode::storageName[storageClass] << ' '; 133 if ( isInline ) os << DeclarationNode::storageName[Inline] << ' '; 134 if ( isNoreturn ) os << DeclarationNode::storageName[Noreturn] << ' '; 153 135 if ( type ) { 154 136 type->print( os, indent ); … … 201 183 } // DeclarationNode::newFunction 202 184 185 DeclarationNode * DeclarationNode::newQualifier( Qualifier q ) { 186 DeclarationNode * newnode = new DeclarationNode; 187 newnode->type = new TypeData(); 188 newnode->type->qualifiers[ q ] = 1; 189 return newnode; 190 } // DeclarationNode::newQualifier 191 192 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) { 193 DeclarationNode * newnode = new DeclarationNode; 194 newnode->type = new TypeData( TypeData::Unknown ); 195 newnode->type->forall = forall; 196 return newnode; 197 } // DeclarationNode::newForall 203 198 204 199 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) { 205 200 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClass es[ sc ] = true;201 newnode->storageClass = sc; 207 202 return newnode; 208 203 } // 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::newFuncSpecifier215 216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) {217 DeclarationNode * newnode = new DeclarationNode;218 newnode->type = new TypeData();219 newnode->type->typeQualifiers[ tq ] = true;220 return newnode;221 } // DeclarationNode::newQualifier222 204 223 205 DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) { … … 248 230 return newnode; 249 231 } // DeclarationNode::newLength 250 251 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) {252 DeclarationNode * newnode = new DeclarationNode;253 newnode->type = new TypeData( TypeData::Unknown );254 newnode->type->forall = forall;255 return newnode;256 } // DeclarationNode::newForall257 232 258 233 DeclarationNode * DeclarationNode::newFromTypedef( string * name ) { … … 453 428 454 429 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 455 const TypeData::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization430 TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 456 431 457 432 if ( (qsrc & qdst).any() ) { // common qualifier ? 458 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) {// find common qualifiers433 for ( int i = 0; i < NoQualifier; i += 1 ) { // find common qualifiers 459 434 if ( qsrc[i] && qdst[i] ) { 460 appendError( error, string( "duplicate " ) + DeclarationNode:: typeQualifierNames[i] );435 appendError( error, string( "duplicate " ) + DeclarationNode::qualifierName[i] ); 461 436 } // if 462 437 } // for 463 } // for438 } // if 464 439 } // DeclarationNode::checkQualifiers 465 440 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; 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 496 461 497 462 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 499 464 } // for 500 465 return this; 501 } // DeclarationNode::copyS pecifiers466 } // DeclarationNode::copyStorageClasses 502 467 503 468 static void addQualifiersToType( TypeData *&src, TypeData * dst ) { … … 516 481 src = nullptr; 517 482 } else { 518 dst-> typeQualifiers |= src->typeQualifiers;483 dst->qualifiers |= src->qualifiers; 519 484 } // if 520 485 } // addQualifiersToType … … 523 488 if ( ! q ) { delete q; return this; } 524 489 525 checkS pecifiers( q );526 copyS pecifiers( q );490 checkStorageClasses( q ); 491 copyStorageClasses( q ); 527 492 528 493 if ( ! q->type ) { … … 553 518 } // if 554 519 555 checkQualifiers( type, q->type );520 checkQualifiers( q->type, type ); 556 521 addQualifiersToType( q->type, type ); 557 522 … … 574 539 switch ( dst->kind ) { 575 540 case TypeData::Unknown: 576 src-> typeQualifiers |= dst->typeQualifiers;541 src->qualifiers |= dst->qualifiers; 577 542 dst = src; 578 543 src = nullptr; 579 544 break; 580 545 case TypeData::Basic: 581 dst-> typeQualifiers |= src->typeQualifiers;546 dst->qualifiers |= src->qualifiers; 582 547 if ( src->kind != TypeData::Unknown ) { 583 548 assert( src->kind == TypeData::Basic ); … … 586 551 dst->basictype = src->basictype; 587 552 } else if ( src->basictype != DeclarationNode::NoBasicType ) 588 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeName s[ src->basictype ] + " in type: ", src );553 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src ); 589 554 590 555 if ( dst->complextype == DeclarationNode::NoComplexType ) { 591 556 dst->complextype = src->complextype; 592 557 } else if ( src->complextype != DeclarationNode::NoComplexType ) 593 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeName s[ src->complextype ] + " in type: ", src );558 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src ); 594 559 595 560 if ( dst->signedness == DeclarationNode::NoSignedness ) { 596 561 dst->signedness = src->signedness; 597 562 } else if ( src->signedness != DeclarationNode::NoSignedness ) 598 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessName s[ src->signedness ] + " in type: ", src );563 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src ); 599 564 600 565 if ( dst->length == DeclarationNode::NoLength ) { … … 603 568 dst->length = DeclarationNode::LongLong; 604 569 } else if ( src->length != DeclarationNode::NoLength ) 605 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthName s[ src->length ] + " in type: ", src );570 throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src ); 606 571 } // if 607 572 break; … … 615 580 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 616 581 } // if 617 dst->base-> typeQualifiers |= src->typeQualifiers;582 dst->base->qualifiers |= src->qualifiers; 618 583 src = nullptr; 619 584 break; … … 634 599 DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) { 635 600 if ( o ) { 636 checkS pecifiers( o );637 copyS pecifiers( o );601 checkStorageClasses( o ); 602 copyStorageClasses( o ); 638 603 if ( o->type ) { 639 604 if ( ! type ) { … … 647 612 type->aggInst.hoistType = o->type->enumeration.body; 648 613 } // if 649 type-> typeQualifiers |= o->type->typeQualifiers;614 type->qualifiers |= o->type->qualifiers; 650 615 } else { 651 616 type = o->type; … … 803 768 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 804 769 } // if 805 p->type->base-> typeQualifiers |= type->typeQualifiers;770 p->type->base->qualifiers |= type->qualifiers; 806 771 break; 807 772 … … 840 805 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 841 806 } // if 842 lastArray->base-> typeQualifiers |= type->typeQualifiers;807 lastArray->base->qualifiers |= type->qualifiers; 843 808 break; 844 809 default: … … 889 854 DeclarationNode * newnode = new DeclarationNode; 890 855 newnode->type = maybeClone( type ); 891 newnode->copySpecifiers( this ); 856 assert( storageClass == NoStorageClass ); 857 newnode->copyStorageClasses( this ); 892 858 assert( newName ); 893 859 newnode->name = newName; … … 898 864 if ( ! o ) return nullptr; 899 865 900 o->copyS pecifiers( this );866 o->copyStorageClasses( this ); 901 867 if ( type ) { 902 868 TypeData * srcType = type; … … 990 956 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 991 957 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 992 auto obj = new ObjectDecl( "", DeclarationNode:: StorageClasses(), linkage, nullptr, inst, nullptr );958 auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 993 959 obj->location = cur->location; 994 960 * out++ = obj; … … 996 962 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 997 963 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 998 auto obj = new ObjectDecl( "", DeclarationNode:: StorageClasses(), linkage, nullptr, inst, nullptr );964 auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 999 965 obj->location = cur->location; 1000 966 * out++ = obj; … … 1039 1005 } // if 1040 1006 1007 // if ( variable.name ) { 1041 1008 if ( variable.tyClass != NoTypeClass ) { 1042 1009 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1043 1010 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1044 1011 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1045 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] ); 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 ] ); 1046 1014 buildList( variable.assertions, ret->get_assertions() ); 1047 1015 return ret; … … 1049 1017 1050 1018 if ( type ) { 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 ); 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 ); 1071 1028 } 1072 1029 … … 1075 1032 1076 1033 if ( attr.expr ) { 1034 // return new AttrType( buildQualifiers( type ), *attr.name, attr.expr->build() ); 1077 1035 return new AttrType( buildQualifiers( type ), *name, attr.expr->build(), attributes ); 1078 1036 } else if ( attr.type ) { 1037 // return new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() ); 1079 1038 return new AttrType( buildQualifiers( type ), *name, attr.type->buildType(), attributes ); 1080 1039 } // if -
src/Parser/ExpressionNode.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 06:58:47 201713 // Update Count : 50 912 // Last Modified On : Fri Sep 16 16:27:44 2016 13 // Update Count : 508 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
rbe8bd88 r87c3bef 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 08:10:53201713 // Update Count : 72612 // Last Modified On : Thu Feb 23 15:22:10 2017 13 // Update Count : 662 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset>22 21 #include <iterator> 23 22 #include <memory> … … 40 39 //############################################################################## 41 40 42 extern char * yyfilename;41 extern char* yyfilename; 43 42 extern int yylineno; 44 43 … … 123 122 } 124 123 125 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }124 Expression * build() const { return const_cast<ExpressionNode*>(this)->expr.release(); } 126 125 private: 127 126 bool extension = false; … … 204 203 // These must remain in the same order as the corresponding DeclarationNode names. 205 204 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 }; 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 }; 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 * 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 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 * ); 230 232 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 );236 static DeclarationNode * newLength( Length );235 static DeclarationNode * newSignedNess( Signedness sn ); 236 static DeclarationNode * newLength( Length lnth ); 237 237 static DeclarationNode * newBuiltinType( BuiltinType ); 238 static DeclarationNode * newForall( DeclarationNode * );239 238 static DeclarationNode * newFromTypedef( std::string * ); 240 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );241 239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 242 240 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body ); … … 265 263 DeclarationNode * addQualifiers( DeclarationNode * ); 266 264 void checkQualifiers( const TypeData *, const TypeData * ); 267 void checkS pecifiers( DeclarationNode * );268 DeclarationNode * copyS pecifiers( DeclarationNode * );265 void checkStorageClasses( DeclarationNode * ); 266 DeclarationNode * copyStorageClasses( DeclarationNode * ); 269 267 DeclarationNode * addType( DeclarationNode * ); 270 268 DeclarationNode * addTypedef(); … … 297 295 298 296 Declaration * build() const; 299 Type * buildType() const;297 ::Type * buildType() const; 300 298 301 299 bool get_hasEllipsis() const; … … 303 301 DeclarationNode * extractAggregate() const; 304 302 bool has_enumeratorValue() const { return (bool)enumeratorValue; } 305 ExpressionNode * consume_enumeratorValue() const { return const_cast<DeclarationNode *>(this)->enumeratorValue.release(); }303 ExpressionNode * consume_enumeratorValue() const { return const_cast<DeclarationNode*>(this)->enumeratorValue.release(); } 306 304 307 305 bool get_extension() const { return extension; } … … 325 323 326 324 TypeData * type; 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 325 StorageClass storageClass; 336 326 ExpressionNode * bitfieldWidth; 327 bool isInline, isNoreturn; 337 328 std::unique_ptr<ExpressionNode> enumeratorValue; 338 329 bool hasEllipsis; … … 351 342 352 343 static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) { 353 Type * ret = orig ? orig->buildType() : nullptr;344 Type* ret = orig ? orig->buildType() : nullptr; 354 345 delete orig; 355 346 return ret; … … 366 357 367 358 virtual StatementNode * clone() const final { assert( false ); return nullptr; } 368 Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }359 Statement * build() const { return const_cast<StatementNode*>(this)->stmt.release(); } 369 360 370 361 virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) { -
src/Parser/TypeData.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 08:08:21201713 // Update Count : 53812 // Last Modified On : Thu Feb 23 21:48:55 2017 13 // Update Count : 485 14 14 // 15 15 … … 157 157 TypeData * TypeData::clone() const { 158 158 TypeData * newtype = new TypeData( kind ); 159 newtype-> typeQualifiers = typeQualifiers;159 newtype->qualifiers = qualifiers; 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 TypeQualifier; i += 1 ) {229 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' ';228 for ( int i = 0; i < DeclarationNode::NoQualifier; i += 1 ) { 229 if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' '; 230 230 } // for 231 231 … … 250 250 break; 251 251 case Basic: 252 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName s[ signedness ] << " ";253 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName s[ length ] << " ";252 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName[ signedness ] << " "; 253 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName[ length ] << " "; 254 254 assert( basictype != DeclarationNode::NoBasicType ); 255 os << DeclarationNode::basicTypeName s[ basictype ] << " ";256 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName s[ complextype ] << " ";255 os << DeclarationNode::basicTypeName[ basictype ] << " "; 256 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName[ complextype ] << " "; 257 257 break; 258 258 case Array: … … 301 301 break; 302 302 case Aggregate: 303 os << DeclarationNode::aggregateName s[ aggregate.kind ] << ' ' << *aggregate.name << endl;303 os << DeclarationNode::aggregateName[ 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:: 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) );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 ) ); 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:: 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) );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 ) ); 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:: 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) );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 ) ); 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:: 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) );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 ) ); 420 420 } // if 421 421 } // for … … 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 495 Type::Qualifiers q; 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 ];;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 ];; 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 s[ td->signedness ] + " in type: ", td );518 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td ); 519 519 } // if 520 520 if ( td->length != DeclarationNode::NoLength ) { 521 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName s[ td->length ] + " in type: ", td );521 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ 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 s[ td->length ] + " in type: ", td );534 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ 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 s[ td->signedness ] + " in type: ", td );564 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ 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 s[ td->length ] + " in type: ", td );567 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ 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 es scs) {734 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClass sc ) { 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 s, typebuild( td->base ) );739 ret = new TypedefDecl( name, sc, typebuild( td->base ) ); 740 740 } else { 741 ret = new TypeDecl( name, sc s, typebuild( td->base ), TypeDecl::Any );741 ret = new TypeDecl( name, sc, 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 es scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {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 ) { 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 s, linkage, buildFunction( td ), body, attributes, funcSpec);794 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt ); 795 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes ); 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 s);802 return buildSymbolic( td, name, sc ); 803 803 } else { 804 return (new ObjectDecl( name, sc s, linkage, bitfieldWidth, typebuild( td ), init, attributes))->set_asmName( asmName );804 return (new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, attributes, isInline, isNoreturn ))->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::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );822 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base, "", DeclarationNode::NoStorageClass, nullptr, false, false, LinkageSpec::Cforall, nullptr ) ) ); 823 823 } // switch 824 824 } else { 825 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );825 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, 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
rbe8bd88 r87c3bef 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 08:03:53201713 // Update Count : 1 7312 // Last Modified On : Thu Feb 23 17:14:46 2017 13 // Update Count : 158 14 14 // 15 15 … … 76 76 DeclarationNode::Length length = DeclarationNode::NoLength; 77 77 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 78 typedef std::bitset< DeclarationNode::No TypeQualifier > TypeQualifiers;79 TypeQualifiers typeQualifiers;78 typedef std::bitset< DeclarationNode::NoQualifier > Qualifiers; 79 Qualifiers qualifiers; 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 ); 109 110 TypeDecl * buildVariable( const TypeData * ); 110 111 EnumDecl * buildEnum( const TypeData *, std::list< Attribute * > ); … … 112 113 TupleType * buildTuple( const TypeData * ); 113 114 TypeofType * buildTypeof( const TypeData * ); 114 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClass es, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );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 * >() ); 115 116 FunctionType * buildFunction( const TypeData * ); 116 117 void buildKRFunction( const TypeData::Function_t & function ); -
src/Parser/lex.ll
rbe8bd88 r87c3bef 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Fri Mar 3 22:18:00 201713 * Update Count : 50 212 * Last Modified On : Tue Nov 29 11:32:00 2016 13 * Update Count : 501 14 14 */ 15 15 … … 235 235 long { KEYWORD_RETURN(LONG); } 236 236 lvalue { KEYWORD_RETURN(LVALUE); } // CFA 237 mutex { KEYWORD_RETURN(MUTEX); } // CFA238 237 _Noreturn { KEYWORD_RETURN(NORETURN); } // C11 239 238 __builtin_offsetof { KEYWORD_RETURN(OFFSETOF); } // GCC -
src/Parser/parser.yy
rbe8bd88 r87c3bef 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 5 15:48:24201713 // Update Count : 22 2712 // Last Modified On : Tue Feb 28 09:58:10 2017 13 // Update Count : 2208 14 14 // 15 15 … … 91 91 // keywords 92 92 %token TYPEDEF 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 93 %token AUTO EXTERN REGISTER STATIC 94 %token INLINE // C99 95 %token FORTRAN // C99, extension ISO/IEC 9899:1999 Section J.5.9(1) 97 96 %token CONST VOLATILE 98 97 %token RESTRICT // C99 99 %token ATOMIC // C11 100 %token FORALL LVALUE MUTEX // CFA 98 %token FORALL LVALUE // CFA 101 99 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 102 100 %token VALIST // GCC … … 104 102 %token TYPEOF LABEL // GCC 105 103 %token ENUM STRUCT UNION 106 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA104 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA 107 105 %token SIZEOF OFFSETOF 108 106 %token ATTRIBUTE EXTENSION // GCC … … 110 108 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT // CFA 111 109 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 112 %token ALIGNAS ALIGNOF GENERIC STATICASSERT// C11110 %token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATICASSERT THREADLOCAL // C11 113 111 114 112 // names and constants: lexer differentiates between identifier and typedef names … … 1402 1400 type_qualifier_name: 1403 1401 CONST 1404 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Const ); }1402 { $$ = DeclarationNode::newQualifier( DeclarationNode::Const ); } 1405 1403 | RESTRICT 1406 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Restrict ); }1404 { $$ = DeclarationNode::newQualifier( DeclarationNode::Restrict ); } 1407 1405 | VOLATILE 1408 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Volatile ); }1406 { $$ = DeclarationNode::newQualifier( DeclarationNode::Volatile ); } 1409 1407 | LVALUE // CFA 1410 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Lvalue ); } 1411 | MUTEX 1412 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Mutex ); } 1408 { $$ = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 1413 1409 | ATOMIC 1414 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Atomic ); }1410 { $$ = DeclarationNode::newQualifier( DeclarationNode::Atomic ); } 1415 1411 | FORALL '(' 1416 1412 { … … 1452 1448 | REGISTER 1453 1449 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 1450 | INLINE // C99 1451 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Inline ); } 1452 { $$ = new DeclarationNode; $$->isInline = true; } 1453 | FORTRAN // C99 1454 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 1455 | NORETURN // C11 1456 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Noreturn ); } 1457 { $$ = new DeclarationNode; $$->isNoreturn = true; } 1454 1458 | THREADLOCAL // C11 1455 1459 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 1456 // Put function specifiers here to simplify parsing rules, but separate them semantically.1457 | INLINE // C991458 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }1459 | FORTRAN // C991460 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }1461 | NORETURN // C111462 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }1463 1460 ; 1464 1461 … … 2036 2033 { $$ = $3->addQualifiers( $1 ); } 2037 2034 | type_declaring_list ',' type_declarator 2038 { $$ = $1->appendList( $3->copyS pecifiers( $1 ) ); }2035 { $$ = $1->appendList( $3->copyStorageClasses( $1 ) ); } 2039 2036 ; 2040 2037 -
src/ResolvExpr/Unify.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sun May 17 12:27:10 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:37:38 201713 // Update Count : 3 912 // Last Modified On : Wed Mar 2 17:37:05 2016 13 // Update Count : 37 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:: StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) );543 dst.push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, t, nullptr ) ); 544 544 } 545 545 delete dcl; -
src/SymTab/Autogen.cc
rbe8bd88 r87c3bef 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:42:44201713 // Update Count : 5112 // Last Modified On : Thu Feb 16 15:02:50 2017 13 // Update Count : 13 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:: StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr );127 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, 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:: StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );136 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, 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:: StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );144 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, 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; 164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ); 163 DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 165 164 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 166 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ), 167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ); 165 FunctionDecl * decl = new FunctionDecl( fname, sc, spec, ftype, new CompoundStmt( noLabels ), true, false ); 168 166 decl->fixUniqueId(); 169 167 return decl; … … 460 458 continue; 461 459 } 462 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );460 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) ); 463 461 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 464 462 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout ); … … 540 538 for ( Declaration * member : aggregateDecl->get_members() ) { 541 539 if ( DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member ) ) { 542 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 );540 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 ); 543 541 544 542 FunctionType * memCtorType = ctorType->clone(); … … 605 603 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 606 604 typeInst->set_baseType( typeDecl ); 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 );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 ); 609 607 610 608 std::list< Statement * > stmts; … … 618 616 } // if 619 617 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 620 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, typeInst, 0 ) );618 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) ); 621 619 type->get_parameters().push_back( dst ); 622 620 type->get_parameters().push_back( src ); … … 717 715 if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) { 718 716 if ( ! done.count( ty->get_baseType() ) ) { 719 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode:: StorageClasses(), nullptr, TypeDecl::Any );717 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::NoStorageClass, nullptr, TypeDecl::Any ); 720 718 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 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 ) ) ); 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 ) ); 729 723 typeParams.push_back( newDecl ); 730 724 done.insert( ty->get_baseType() ); -
src/SymTab/Autogen.h
rbe8bd88 r87c3bef 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:33:01201713 // Update Count : 412 // Last Modified On : Wed Feb 1 16:31:00 2017 13 // Update Count : 2 14 14 // 15 15 … … 102 102 } 103 103 104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode:: StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, 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
rbe8bd88 r87c3bef 10 10 // Created On : Sun May 17 16:19:49 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:36:59 201713 // Update Count : 612 // Last Modified On : Wed Mar 2 17:31:10 2016 13 // Update Count : 3 14 14 // 15 15 … … 21 21 22 22 namespace SymTab { 23 FixFunction::FixFunction() : isVoid( false ) {} 23 FixFunction::FixFunction() : isVoid( false ) { 24 } 24 25 25 26 DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) { 26 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass es(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() );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() ); 27 28 functionDecl->get_attributes().clear(); 28 29 delete functionDecl; -
src/SymTab/Indexer.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sun May 17 21:37:33 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:45:32201713 // Update Count : 1 612 // Last Modified On : Thu Feb 16 14:59:19 2017 13 // Update Count : 13 14 14 // 15 15 … … 738 738 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added ); 739 739 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing ); 740 if ( ! newobj->get_storageClasses()[ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ]) {740 if ( newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) { 741 741 throw SemanticError( "duplicate object definition for ", added ); 742 742 } // if -
src/SymTab/Validate.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:51:36201713 // Update Count : 3 4912 // Last Modified On : Thu Feb 23 21:33:55 2017 13 // Update Count : 318 14 14 // 15 15 … … 97 97 class ReturnTypeFixer final : public Visitor { 98 98 public: 99 99 100 typedef Visitor Parent; 100 101 using Parent::visit; … … 103 104 104 105 virtual void visit( FunctionDecl * functionDecl ); 106 105 107 virtual void visit( FunctionType * ftype ); 106 108 }; … … 159 161 private: 160 162 virtual void visit( FunctionDecl * functionDecl ); 163 161 164 virtual void visit( ReturnStmt * returnStmt ); 162 165 … … 208 211 209 212 class CompoundLiteral final : public GenPoly::DeclMutator { 210 DeclarationNode::StorageClass es storageClasses;213 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass; 211 214 212 215 using GenPoly::DeclMutator::mutate; … … 657 660 // Note, qualifiers on the typedef are superfluous for the forward declaration. 658 661 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) { 659 return new StructDecl( aggDecl->get_name() );662 return aggDecl->get_baseStruct() ? Mutator::mutate( aggDecl->get_baseStruct() ) : new StructDecl( aggDecl->get_name() ); 660 663 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) { 661 return new UnionDecl( aggDecl->get_name() );664 return aggDecl->get_baseUnion() ? Mutator::mutate( aggDecl->get_baseUnion() ) : new UnionDecl( aggDecl->get_name() ); 662 665 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( tyDecl->get_base() ) ) { 663 666 return new EnumDecl( enumDecl->get_name() ); … … 688 691 DeclarationWithType *ret = Mutator::mutate( objDecl ); 689 692 typedefNames.endScope(); 690 691 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { // function type?693 // is the type a function? 694 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { 692 695 // replace the current object declaration with a function declaration 693 FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClass es(), ret->get_linkage(), funtype, 0, objDecl->get_attributes(), ret->get_funcSpec() );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() ); 694 697 objDecl->get_attributes().clear(); 695 698 objDecl->set_type( nullptr ); 696 699 delete objDecl; 697 700 return newDecl; 701 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) { 702 throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl ); 698 703 } // if 699 704 return ret; … … 754 759 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 755 760 } // if 756 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode:: StorageClasses(), type ) );761 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::NoStorageClass, type ) ); 757 762 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel ); 758 763 } // if … … 808 813 809 814 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) { 810 storage Classes = objectDecl->get_storageClasses();815 storageclass = objectDecl->get_storageClass(); 811 816 DeclarationWithType * temp = Mutator::mutate( objectDecl ); 817 storageclass = DeclarationNode::NoStorageClass; 812 818 return temp; 813 819 } … … 818 824 static UniqueName indexName( "_compLit" ); 819 825 820 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storage Classes, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );826 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageclass, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() ); 821 827 compLitExpr->set_type( 0 ); 822 828 compLitExpr->set_initializer( 0 ); … … 857 863 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 858 864 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 859 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode:: StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );865 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 860 866 deleteAll( retVals ); 861 867 retVals.clear(); -
src/SynTree/AggregateDecl.cc
rbe8bd88 r87c3bef 10 10 // Created On : Sun May 17 23:56:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:31:47201713 // Update Count : 1 912 // Last Modified On : Mon Feb 6 15:31:23 2017 13 // Update Count : 17 14 14 // 15 15 … … 20 20 21 21 22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode:: StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode::NoStorageClass, LinkageSpec::Cforall ), body( false ), attributes( attributes ) { 23 23 } 24 24 -
src/SynTree/Declaration.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:31:11201713 // Update Count : 2312 // Last Modified On : Thu Feb 9 14:28:05 2017 13 // Update Count : 16 14 14 // 15 15 … … 27 27 static IdMapType idMap; 28 28 29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClass es scs, LinkageSpec::Spec linkage )30 : name( name ), storageClass es( scs ), linkage( linkage ), uniqueId( 0 ) {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 ) { 31 31 } 32 32 33 33 Declaration::Declaration( const Declaration &other ) 34 : name( other.name ), storageClass es( other.storageClasses ), linkage( other.linkage), uniqueId( other.uniqueId ) {34 : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), isInline( other.isInline ), isNoreturn( other.isNoreturn ), uniqueId( other.uniqueId ) { 35 35 } 36 36 … … 66 66 67 67 68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode:: StorageClasses(), LinkageSpec::C ), stmt( stmt ) {68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode::NoStorageClass, LinkageSpec::C ), stmt( stmt ) { 69 69 } 70 70 -
src/SynTree/Declaration.h
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:40:42201713 // Update Count : 11312 // Last Modified On : Thu Feb 16 14:53:35 2017 13 // Update Count : 57 14 14 // 15 15 … … 28 28 class Declaration : public BaseSyntaxNode { 29 29 public: 30 Declaration( const std::string &name, DeclarationNode::StorageClass es scs, LinkageSpec::Spec linkage );30 Declaration( const std::string &name, DeclarationNode::StorageClass sc, 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 37 DeclarationNode::StorageClasses get_storageClasses() const { return storageClasses; } 38 36 DeclarationNode::StorageClass get_storageClass() const { return storageClass; } 37 void set_storageClass( DeclarationNode::StorageClass newValue ) { storageClass = newValue; } 39 38 LinkageSpec::Spec get_linkage() const { return linkage; } 40 39 void set_linkage( LinkageSpec::Spec newValue ) { linkage = newValue; } 41 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; } 42 44 UniqueId get_uniqueId() const { return uniqueId; } 43 44 45 bool get_extension() const { return extension; } 45 46 Declaration *set_extension( bool exten ) { extension = exten; return this; } … … 56 57 private: 57 58 std::string name; 58 DeclarationNode::StorageClass es storageClasses;59 DeclarationNode::StorageClass storageClass; 59 60 LinkageSpec::Spec linkage; 61 bool isInline, isNoreturn; 60 62 UniqueId uniqueId; 61 63 bool extension = false; … … 64 66 class DeclarationWithType : public Declaration { 65 67 public: 66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass es scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs );68 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes ); 67 69 DeclarationWithType( const DeclarationWithType &other ); 68 70 virtual ~DeclarationWithType(); … … 81 83 std::list< Attribute * >& get_attributes() { return attributes; } 82 84 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; }86 85 87 86 virtual DeclarationWithType *clone() const = 0; … … 98 97 ConstantExpr *asmName; 99 98 std::list< Attribute * > attributes; 100 DeclarationNode::FuncSpecifiers fs;101 99 }; 102 100 … … 104 102 typedef DeclarationWithType Parent; 105 103 public: 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() ); 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 ); 108 105 ObjectDecl( const ObjectDecl &other ); 109 106 virtual ~ObjectDecl(); … … 132 129 typedef DeclarationWithType Parent; 133 130 public: 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() ); 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 * >() ); 136 132 FunctionDecl( const FunctionDecl &other ); 137 133 virtual ~FunctionDecl(); … … 158 154 typedef Declaration Parent; 159 155 public: 160 NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass es scs, Type *type );156 NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type ); 161 157 NamedTypeDecl( const NamedTypeDecl &other ); 162 158 virtual ~NamedTypeDecl(); … … 193 189 }; 194 190 195 TypeDecl( const std::string &name, DeclarationNode::StorageClass es scs, Type *type, Kind kind );191 TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ); 196 192 TypeDecl( const TypeDecl &other ); 197 193 … … 214 210 typedef NamedTypeDecl Parent; 215 211 public: 216 TypedefDecl( const std::string &name, DeclarationNode::StorageClass es scs, Type *type ) : Parent( name, scs, type ) {}212 TypedefDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type ) : Parent( name, sc, type ) {} 217 213 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 218 214 -
src/SynTree/DeclarationWithType.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:32:14 201713 // Update Count : 2312 // Last Modified On : Tue Dec 13 14:49:43 2016 13 // Update Count : 7 14 14 // 15 15 … … 19 19 #include "Common/utility.h" 20 20 21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass es scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs )22 : Declaration( name, sc s, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) {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 ) { 23 23 } 24 24 25 25 DeclarationWithType::DeclarationWithType( const DeclarationWithType &other ) 26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) , fs( other.fs ){26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) { 27 27 cloneAll( other.attributes, attributes ); 28 28 asmName = maybeClone( other.asmName ); -
src/SynTree/FunctionDecl.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:54:58201713 // Update Count : 6812 // Last Modified On : Thu Feb 16 15:01:52 2017 13 // Update Count : 23 14 14 // 15 15 … … 26 26 extern bool translation_unit_nomain; 27 27 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 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 31 34 if ( name == "main" ) { 32 35 set_linkage( CodeGen::FixMain::mainLinkage() ); … … 35 38 36 39 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 37 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {40 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 38 41 } 39 42 … … 62 65 os << LinkageSpec::linkageName( get_linkage() ) << " "; 63 66 } // if 67 if ( get_isInline() ) { 68 os << "inline "; 69 } // if 70 if ( get_isNoreturn() ) { 71 os << "_Noreturn "; 72 } // if 64 73 65 74 printAll( get_attributes(), os, indent ); 66 75 67 DeclarationNode::print_StorageClass( os, get_storageClasses() );68 DeclarationNode::print_FuncSpec( os, get_funcSpec() );69 76 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 77 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 78 } // if 70 79 if ( get_type() ) { 71 80 get_type()->print( os, indent ); … … 88 97 os << get_name() << ": "; 89 98 } // if 99 if ( get_isInline() ) { 100 os << "inline "; 101 } // if 102 if ( get_isNoreturn() ) { 103 os << "_Noreturn "; 104 } // if 90 105 91 106 // xxx - should printShort print attributes? 92 107 93 DeclarationNode::print_StorageClass( os, get_storageClasses() );94 DeclarationNode::print_FuncSpec( os, get_funcSpec() );95 108 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 109 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 110 } // if 96 111 if ( get_type() ) { 97 112 get_type()->print( os, indent ); -
src/SynTree/NamedTypeDecl.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:39:41 201713 // Update Count : 1012 // Last Modified On : Sat Jun 13 08:13:55 2015 13 // Update Count : 3 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass es scs, Type *base )21 : Parent( name, sc s, LinkageSpec::Cforall ), base( base ) {}20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *base ) 21 : Parent( name, sc, LinkageSpec::Cforall ), base( base ) {} 22 22 23 23 NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other ) … … 39 39 os << get_name() << ": "; 40 40 } // if 41 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 41 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 42 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 43 } // if 42 44 os << typeString(); 43 45 if ( base ) { … … 61 63 os << get_name() << ": "; 62 64 } // if 63 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 65 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 66 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 67 } // if 64 68 os << typeString(); 65 69 if ( base ) { -
src/SynTree/ObjectDecl.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:55:24 201713 // Update Count : 5412 // Last Modified On : Sat Oct 1 23:05:56 2016 13 // Update Count : 32 14 14 // 15 15 … … 22 22 #include "Statement.h" 23 23 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 ) { 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 ); 26 28 } 27 29 … … 47 49 printAll( get_attributes(), os, indent ); 48 50 49 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 51 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 52 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 53 } // if 50 54 51 55 if ( get_type() ) { … … 81 85 // xxx - should printShort print attributes? 82 86 83 DeclarationNode::print_StorageClass( os, get_storageClasses() ); 87 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 88 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; 89 } // if 84 90 85 91 if ( get_type() ) { -
src/SynTree/Type.h
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 1 09:11:45201713 // Update Count : 4112 // Last Modified On : Thu Feb 23 16:38:53 2017 13 // Update Count : 34 14 14 // 15 15 … … 21 21 #include "SynTree.h" 22 22 #include "Visitor.h" 23 #include "Common/utility.h" 23 24 24 25 class Type : public BaseSyntaxNode { … … 212 213 bool get_isVarArgs() const { return isVarArgs; } 213 214 void set_isVarArgs( bool newValue ) { isVarArgs = newValue; } 215 214 216 bool isTtype() const; 215 217 -
src/SynTree/TypeDecl.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:39:09 201713 // Update Count : 412 // Last Modified On : Sat Jun 13 08:14:35 2015 13 // Update Count : 2 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass es scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {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 ) { 21 21 } 22 22 -
src/Tuples/TupleAssignment.cc
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:40:14201713 // Update Count : 512 // Last Modified On : Wed Feb 1 16:40:16 2017 13 // Update Count : 3 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:: StorageClasses(), LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );242 ObjectDecl * ret = new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, 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
rbe8bd88 r87c3bef 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:43:56201713 // Update Count : 1212 // Last Modified On : Wed Feb 1 16:40:40 2017 13 // Update Count : 3 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:: StorageClasses(), 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::NoStorageClass, 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::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 ) );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 ) ); 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:: StorageClasses(), LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );229 decl->get_members().push_back( new ObjectDecl( "dummy", DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 230 230 } 231 231 typeMap[tupleSize] = decl; -
src/benchmark/Makefile.am
rbe8bd88 r87c3bef 18 18 CFLAGS = 19 19 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 20 CC = @CFA_BINDIR@/ @CFA_NAME@20 CC = @CFA_BINDIR@/cfa 21 21 22 22 noinst_PROGRAMS = bench ctxswitch-coroutine ctxswitch-thread -
src/benchmark/Makefile.in
rbe8bd88 r87c3bef 94 94 AWK = @AWK@ 95 95 BACKEND_CC = @BACKEND_CC@ 96 CC = @CFA_BINDIR@/ @CFA_NAME@96 CC = @CFA_BINDIR@/cfa 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@107 106 CFA_PREFIX = @CFA_PREFIX@ 108 107 -
src/driver/Makefile.am
rbe8bd88 r87c3bef 28 28 endif 29 29 30 noinst_PROGRAMS = cfa30 bin_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 41 33 # put into lib for now 42 cc1libdir = ${ CFA_LIBDIR}34 cc1libdir = ${libdir} 43 35 cc1lib_PROGRAMS = cc1 44 36 cc1_SOURCES = cc1.cc 45 37 46 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME)@CFA_PREFIX@/lib/${cc1lib_PROGRAMS}38 MAINTAINERCLEANFILES = @CFA_PREFIX@/bin/${bin_PROGRAMS} @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} -
src/driver/Makefile.in
rbe8bd88 r87c3bef 41 41 @BUILD_DEBUG_TRUE@am__append_2 = -DHAVE_LIBCFA_DEBUG 42 42 @BUILD_RELEASE_TRUE@am__append_3 = -DHAVE_LIBCFA_RELEASE 43 noinst_PROGRAMS = cfa$(EXEEXT)43 bin_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)$( cc1libdir)"56 PROGRAMS = $( cc1lib_PROGRAMS) $(noinst_PROGRAMS)55 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cc1libdir)" 56 PROGRAMS = $(bin_PROGRAMS) $(cc1lib_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@109 108 CFA_PREFIX = @CFA_PREFIX@ 110 109 CFLAGS = @CFLAGS@ … … 213 212 214 213 # put into lib for now 215 cc1libdir = ${ CFA_LIBDIR}214 cc1libdir = ${libdir} 216 215 cc1_SOURCES = cc1.cc 217 MAINTAINERCLEANFILES = $(CFA_BINDIR)/$(CFA_NAME)@CFA_PREFIX@/lib/${cc1lib_PROGRAMS}216 MAINTAINERCLEANFILES = @CFA_PREFIX@/bin/${bin_PROGRAMS} @CFA_PREFIX@/lib/${cc1lib_PROGRAMS} 218 217 all: all-am 219 218 … … 250 249 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 251 250 $(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 ; done 275 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 $$files 285 286 clean-binPROGRAMS: 287 -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 252 288 install-cc1libPROGRAMS: $(cc1lib_PROGRAMS) 253 289 @$(NORMAL_INSTALL) … … 287 323 clean-cc1libPROGRAMS: 288 324 -test -z "$(cc1lib_PROGRAMS)" || rm -f $(cc1lib_PROGRAMS) 289 290 clean-noinstPROGRAMS:291 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)292 325 cc1$(EXEEXT): $(cc1_OBJECTS) $(cc1_DEPENDENCIES) $(EXTRA_cc1_DEPENDENCIES) 293 326 @rm -f cc1$(EXEEXT) … … 406 439 all-am: Makefile $(PROGRAMS) 407 440 installdirs: 408 for dir in "$(DESTDIR)$( cc1libdir)"; do \441 for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cc1libdir)"; do \ 409 442 test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 410 443 done … … 442 475 clean: clean-am 443 476 444 clean-am: clean- cc1libPROGRAMS clean-generic clean-noinstPROGRAMS\477 clean-am: clean-binPROGRAMS clean-cc1libPROGRAMS clean-generic \ 445 478 mostlyclean-am 446 479 … … 469 502 install-dvi-am: 470 503 471 install-exec-am: 472 @$(NORMAL_INSTALL) 473 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook 504 install-exec-am: install-binPROGRAMS 505 474 506 install-html: install-html-am 475 507 … … 509 541 ps-am: 510 542 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 \ 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 \ 523 554 install-info-am install-man install-pdf install-pdf-am \ 524 555 install-ps install-ps-am install-strip installcheck \ … … 526 557 maintainer-clean-generic mostlyclean mostlyclean-compile \ 527 558 mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ 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) 559 uninstall-am uninstall-binPROGRAMS uninstall-cc1libPROGRAMS 560 538 561 539 562 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/examples/Makefile.am
rbe8bd88 r87c3bef 18 18 CFLAGS = 19 19 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 20 CC = @CFA_BINDIR@/ @CFA_NAME@20 CC = @CFA_BINDIR@/cfa 21 21 22 22 noinst_PROGRAMS = fstream_test vector_test avl_test Bench # build but do not install -
src/examples/Makefile.in
rbe8bd88 r87c3bef 105 105 AWK = @AWK@ 106 106 BACKEND_CC = @BACKEND_CC@ 107 CC = @CFA_BINDIR@/ @CFA_NAME@107 CC = @CFA_BINDIR@/cfa 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@118 117 CFA_PREFIX = @CFA_PREFIX@ 119 118 -
src/libcfa/Makefile.am
rbe8bd88 r87c3bef 18 18 AUTOMAKE_OPTIONS = subdir-objects 19 19 20 libdir = ${CFA_LIBDIR}21 20 lib_LIBRARIES = 22 21 … … 68 67 ${libobjs} : ${abs_top_srcdir}/src/driver/cfa-cpp ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator 69 68 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 = $( CFA_INCDIR)77 cfa_includedir = $(includedir)/cfa 78 78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h 79 79 … … 81 81 82 82 maintainer-clean-local: 83 -rm -rf ${ CFA_INCDIR} ${CFA_LIBDIR}83 -rm -rf ${includedir}/* -
src/libcfa/Makefile.in
rbe8bd88 r87c3bef 201 201 CFA_INCDIR = @CFA_INCDIR@ 202 202 CFA_LIBDIR = @CFA_LIBDIR@ 203 CFA_NAME = @CFA_NAME@204 203 CFA_PREFIX = @CFA_PREFIX@ 205 204 CFLAGS = -quiet -no-include-stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS} … … 282 281 infodir = @infodir@ 283 282 install_sh = @install_sh@ 284 libdir = ${CFA_LIBDIR}283 libdir = @libdir@ 285 284 libexecdir = @libexecdir@ 286 285 localedir = @localedir@ … … 316 315 libcfa_d_a_CFLAGS = -debug -O0 317 316 stdhdr = ${shell echo stdhdr/*} 318 cfa_includedir = $( CFA_INCDIR)317 cfa_includedir = $(includedir)/cfa 319 318 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h 320 319 CLEANFILES = libcfa-prelude.c … … 1161 1160 1162 1161 maintainer-clean-local: 1163 -rm -rf ${ CFA_INCDIR} ${CFA_LIBDIR}1162 -rm -rf ${includedir}/* 1164 1163 1165 1164 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/libcfa/iostream
rbe8bd88 r87c3bef 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 20:51:35201713 // Update Count : 9 812 // Last Modified On : Fri Feb 24 21:09:09 2017 13 // Update Count : 94 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 70 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) ); 73 71 // manipulators 74 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) );75 72 forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * ); 76 73 forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * ); -
src/libcfa/iostream.c
rbe8bd88 r87c3bef 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 20:52:02201713 // Update Count : 3 1312 // Last Modified On : Fri Feb 24 21:09:59 2017 13 // Update Count : 307 14 14 // 15 15 … … 155 155 enum { Open = 1, Close, OpenClose }; 156 156 static const unsigned char mask[256] = { 157 // opening delimiters , no space after157 // opening delimiters 158 158 ['('] : Open, ['['] : Open, ['{'] : Open, 159 ['$'] : Open, [ '='] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,159 ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, 160 160 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 161 // closing delimiters , no space before161 // closing delimiters 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 , no space before or after165 // opening-closing delimiters 166 166 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, 167 167 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace … … 198 198 199 199 200 // tuples201 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 // manipulators209 200 forall( dtype ostype | ostream( ostype ) ) 210 201 ostype * ?|?( ostype * os, ostype * (* manip)( ostype * ) ) { -
src/libcfa/stdlib
rbe8bd88 r87c3bef 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 22:03:54201713 // Update Count : 10 212 // Last Modified On : Fri Feb 24 21:07:16 2017 13 // Update Count : 101 14 14 // 15 15 -
src/libcfa/stdlib.c
rbe8bd88 r87c3bef 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 22:02:22201713 // Update Count : 17 212 // Last Modified On : Fri Feb 24 21:08:11 2017 13 // Update Count : 171 14 14 // 15 15 -
src/prelude/Makefile.am
rbe8bd88 r87c3bef 19 19 20 20 # put into lib for now 21 cfalibdir = ${ CFA_LIBDIR}21 cfalibdir = ${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
rbe8bd88 r87c3bef 105 105 CFA_INCDIR = @CFA_INCDIR@ 106 106 CFA_LIBDIR = @CFA_LIBDIR@ 107 CFA_NAME = @CFA_NAME@108 107 CFA_PREFIX = @CFA_PREFIX@ 109 108 CFLAGS = @CFLAGS@ … … 210 209 211 210 # put into lib for now 212 cfalibdir = ${ CFA_LIBDIR}211 cfalibdir = ${libdir} 213 212 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c 214 213 noinst_DATA = ../libcfa/libcfa-prelude.c -
src/tests/.expect/tupleAssign.txt
rbe8bd88 r87c3bef 1 u=5 v=6 x=10 y=11 z=[100, 200]2 1 u=5 v=6 x=10 y=11 z=[100, 200] 3 2 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]6 3 u=10 v=11 z=[10, 11] 7 4 u=123 v=456 z=[111, 222] 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] 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] -
src/tests/Makefile.am
rbe8bd88 r87c3bef 30 30 EXTRA_FLAGS = 31 31 CFLAGS = -g -Wall -Wno-unused-function @CFA_FLAGS@ ${EXTRA_FLAGS} 32 CC = @CFA_BINDIR@/ @CFA_NAME@32 CC = @CFA_BINDIR@/cfa 33 33 34 34 .PHONY : list -
src/tests/Makefile.in
rbe8bd88 r87c3bef 113 113 AWK = @AWK@ 114 114 BACKEND_CC = @BACKEND_CC@ 115 CC = @CFA_BINDIR@/ @CFA_NAME@115 CC = @CFA_BINDIR@/cfa 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@126 125 CFA_PREFIX = @CFA_PREFIX@ 127 126 CFLAGS = -g -Wall -Wno-unused-function @CFA_FLAGS@ ${EXTRA_FLAGS} -
src/tests/tupleAssign.c
rbe8bd88 r87c3bef 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Nov 15 17:24:32 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Mar 6 21:23:58 201713 // Update Count : 3 411 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 15 17:27:28 2016 13 // Update Count : 3 14 14 // 15 16 #include <fstream>17 15 18 16 int main() { … … 23 21 24 22 // swap x, y and store the new [x, y] in [u, v] and in 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; 23 printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z); 27 24 z = [u, v] = [x, y] = [y, x]; 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; 25 printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z); 30 26 31 27 // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v 32 28 [v, z, u] = [z, u, v]; 33 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 34 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl; 29 printf("u=%d v=%d z=[%d, %d]\n", u, v, z); 35 30 36 31 // multiple assignment with tuple expression on right 37 32 z = [111, 222]; 38 33 [u, v] = [123, 456]; 39 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 40 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl; 34 printf("u=%d v=%d z=[%d, %d]\n", u, v, z); 41 35 } 36 42 37 { 43 38 // test mass assignment … … 53 48 // no conversion from X to integral types, so this serves as a santiy 54 49 // check that as long as this compiles, ?=?(_, x) is not generated. 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; 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); 61 54 } 62 55 }
Note:
See TracChangeset
for help on using the changeset viewer.