Changeset 3b8e52c
- Timestamp:
- Aug 17, 2016, 11:09:11 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 1cb2282, 7a5d773
- Parents:
- 926af74
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r926af74 r3b8e52c 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 16 18:00:34201613 // Update Count : 1 7912 // Last Modified On : Wed Aug 17 11:08:56 2016 13 // Update Count : 180 14 14 // 15 15 … … 780 780 781 781 DeclarationNode *DeclarationNode::appendList( DeclarationNode *node ) { 782 if ( node != 0 ) { 783 set_last( node ); 784 } // if 785 return this; 782 return (DeclarationNode *)set_last( node ); 786 783 } 787 784 -
src/Parser/LinkageSpec.cc
r926af74 r3b8e52c 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:22:09 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 1 9 15:53:05 201513 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 23:02:37 2016 13 // Update Count : 11 14 14 // 15 15 … … 31 31 32 32 std::string LinkageSpec::toString( LinkageSpec::Type linkage ) { 33 switch ( linkage ) { 34 case Intrinsic: 35 return "intrinsic"; 36 case Cforall: 37 return "Cforall"; 38 case C: 39 return "C"; 40 case AutoGen: 41 return "automatically generated"; 42 case Compiler: 43 return "compiler built-in"; 44 } 45 assert( false ); 46 return ""; 33 static const char *linkageKinds[LinkageSpec::NoOfTypes] = { 34 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", 35 }; 36 return linkageKinds[linkage]; 47 37 } 48 38 49 39 bool LinkageSpec::isDecoratable( Type t ) { 50 switch ( t ) { 51 case Intrinsic: 52 case Cforall: 53 case AutoGen: 54 return true; 55 case C: 56 case Compiler: 57 return false; 58 } 59 assert( false ); 60 return false; 40 static bool decoratable[LinkageSpec::NoOfTypes] = { 41 // Intrinsic, Cforall, C, AutoGen, Compiler 42 true, true, false, true, false, 43 }; 44 return decoratable[ t ]; 61 45 } 62 46 63 47 bool LinkageSpec::isGeneratable( Type t ) { 64 switch ( t ) { 65 case Intrinsic: 66 case Cforall: 67 case AutoGen: 68 case C: 69 return true; 70 case Compiler: 71 return false; 72 } 73 assert( false ); 74 return false; 48 static bool generatable[LinkageSpec::NoOfTypes] = { 49 // Intrinsic, Cforall, C, AutoGen, Compiler 50 true, true, true, true, false, 51 }; 52 return generatable[ t ]; 75 53 } 76 54 … … 81 59 82 60 bool LinkageSpec::isOverridable( Type t ) { 83 switch ( t ) { 84 case Intrinsic: 85 case AutoGen: 86 return true; 87 case Cforall: 88 case C: 89 case Compiler: 90 return false; 91 } 92 assert( false ); 93 return false; 61 static bool overridable[LinkageSpec::NoOfTypes] = { 62 // Intrinsic, Cforall, C, AutoGen, Compiler 63 true, false, false, true, false, 64 }; 65 return overridable[ t ]; 94 66 } 95 67 96 68 bool LinkageSpec::isBuiltin( Type t ) { 97 switch ( t ) { 98 case Cforall: 99 case AutoGen: 100 case C: 101 return false; 102 case Intrinsic: 103 case Compiler: 104 return true; 105 } 106 assert( false ); 107 return false; 69 static bool builtin[LinkageSpec::NoOfTypes] = { 70 // Intrinsic, Cforall, C, AutoGen, Compiler 71 true, false, false, false, true, 72 }; 73 return builtin[ t ]; 108 74 } 109 75 -
src/Parser/LinkageSpec.h
r926af74 r3b8e52c 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Aug 18 14:11:55 201513 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 22:19:48 2016 13 // Update Count : 6 14 14 // 15 15 … … 25 25 C, // not overloadable, not mangled 26 26 AutoGen, // built by translator (struct assignment) 27 Compiler // gcc internal 27 Compiler, // gcc internal 28 NoOfTypes 28 29 }; 29 30 -
src/Parser/parser.cc
r926af74 r3b8e52c 7801 7801 #line 1993 "parser.yy" 7802 7802 { 7803 linkageStack.push( linkage ); 7803 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 7804 7804 linkage = LinkageSpec::fromString( *(yyvsp[(2) - (2)].tok) ); 7805 7805 } -
src/Parser/parser.yy
r926af74 r3b8e52c 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 16 21:59:35201613 // Update Count : 190 712 // Last Modified On : Wed Aug 17 11:18:40 2016 13 // Update Count : 1908 14 14 // 15 15 … … 1992 1992 | EXTERN STRINGliteral 1993 1993 { 1994 linkageStack.push( linkage ); 1994 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 1995 1995 linkage = LinkageSpec::fromString( *$2 ); 1996 1996 } -
src/main.cc
r926af74 r3b8e52c 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 09:08:43201613 // Update Count : 27412 // Last Modified On : Wed Aug 17 22:13:38 2016 13 // Update Count : 341 14 14 // 15 15 … … 70 70 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout ); 71 71 72 //************************************************ 73 74 #define __STRINGIFY__(str) #str 75 #define __VSTRINGIFY__(str) __STRINGIFY__(str) 76 #define assertf(expr, fmt, ...) ((expr) ? static_cast<void>(0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) 77 #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\": " 78 79 extern const char * __progname; // global name of running executable (argv[0]) 80 // called by macro assert in assert.h 81 void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { 82 fprintf( stderr, CFA_ASSERT_FMT, __progname, function, line, file ); 83 exit( EXIT_FAILURE ); 84 } 85 86 #include <cstdarg> 87 // called by macro assertf 88 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { 89 fprintf( stderr, CFA_ASSERT_FMT, __progname, function, line, file ); 90 va_list args; 91 va_start( args, fmt ); 92 vfprintf( stderr, fmt, args ); 93 exit( EXIT_FAILURE ); 94 } 95 96 //************************************************ 72 97 73 98 int main( int argc, char * argv[] ) { 74 FILE * input; 99 FILE * input; // use FILE rather than istream because yyin is FILE 75 100 std::ostream *output = & std::cout; 76 101 std::list< Declaration * > translationUnit; … … 81 106 try { 82 107 // choose to read the program from a file or stdin 83 if ( optind < argc ) { 108 if ( optind < argc ) { // any commands after the flags ? => input file name 84 109 input = fopen( argv[ optind ], "r" ); 85 if ( ! input ) { 86 std::cout << "Error: cannot open " << argv[ optind ] << std::endl; 87 exit( EXIT_FAILURE ); 88 } // if 110 assertf( input, "cannot open %s\n", argv[ optind ] ); 89 111 // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to) 90 112 if ( filename == nullptr ) filename = argv[ optind ]; … … 92 114 if ( libcfap ) filename = "prelude.cf"; 93 115 optind += 1; 94 } else { 116 } else { // no input file name 95 117 input = stdin; 96 118 // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass … … 99 121 } // if 100 122 101 if ( optind < argc ) { 123 if ( optind < argc ) { // any commands after the flags and input file ? => output file name 102 124 output = new ofstream( argv[ optind ] ); 103 125 } // if … … 107 129 // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here. 108 130 FILE * builtins = fopen( libcfap | treep ? "builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" ); 109 if ( builtins == nullptr ) { 110 std::cerr << "Error: cannot open builtins.cf" << std::endl; 111 exit( EXIT_FAILURE ); 112 } // if 131 assertf( builtins, "cannot open builtins.cf\n" ); 113 132 parse( builtins, LinkageSpec::Compiler ); 114 133 115 134 // read the extra prelude in, if not generating the cfa library 116 135 FILE * extras = fopen( libcfap | treep ? "extras.cf" : CFA_LIBDIR "/extras.cf", "r" ); 117 if ( extras == nullptr ) { 118 std::cerr << "Error: cannot open extras.cf" << std::endl; 119 exit( EXIT_FAILURE ); 120 } // if 136 assertf( extras, "cannot open extras.cf\n" ); 121 137 parse( extras, LinkageSpec::C ); 122 138 … … 124 140 // read the prelude in, if not generating the cfa library 125 141 FILE * prelude = fopen( treep ? "prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" ); 126 if ( prelude == nullptr ) { 127 std::cerr << "Error: cannot open prelude.cf" << std::endl; 128 exit( EXIT_FAILURE ); 129 } // if 130 142 assertf( prelude, "cannot open prelude.cf\n" ); 131 143 parse( prelude, LinkageSpec::Intrinsic ); 132 144 } // if … … 355 367 break; 356 368 case '?': 357 cout << "Unknown option: '" << (char)optopt << "'" << endl; 358 exit( EXIT_FAILURE ); 369 assertf( false, "Unknown option: '%c'\n", (char)optopt ); 359 370 default: 360 371 abort(); … … 397 408 } // dump 398 409 410 411 399 412 // Local Variables: // 400 413 // tab-width: 4 // -
src/tests/.expect/32/gccExtensions.txt
r926af74 r3b8e52c 11 11 asm ( "nop" : : : ); 12 12 static int __y__i_2; 13 static int *__z__Pi_2; 13 14 int __src__i_2; 14 15 int __dst__i_2; … … 23 24 const int __i2__Ci_2; 24 25 const int __i3__Ci_2; 26 inline int __f1__Fi___2(){ 27 } 28 inline int __f2__Fi___2(){ 29 } 30 int __s1__i_2; 31 int __s2__i_2; 32 volatile int __v1__Vi_2; 33 volatile int __v2__Vi_2; 34 int __t1___2; 35 int __t2___2; 25 36 __extension__ const int __ex__Ci_2; 26 37 struct S { … … 73 84 ((void)(__extension__ __a__i_2=(__extension__ __b__i_2+__extension__ __c__i_2))); 74 85 ((void)(__extension__ __a__i_2=__extension__ (__extension__ __b__i_2+__extension__ __c__i_2))); 75 inline int __f1__Fi___2(){76 }77 inline int __f2__Fi___2(){78 }79 int __s1__i_2;80 int __s2__i_2;81 int __t1___2;82 int __t2___2;83 volatile int __v1__Vi_2;84 volatile int __v2__Vi_2;85 86 int __a1__i_2; 86 87 const int __a2__Ci_2;
Note: See TracChangeset
for help on using the changeset viewer.