Changes in / [7a5d773:6643e72]
- Location:
- src
- Files:
-
- 7 edited
-
Parser/DeclarationNode.cc (modified) (2 diffs)
-
Parser/LinkageSpec.cc (modified) (3 diffs)
-
Parser/LinkageSpec.h (modified) (2 diffs)
-
Parser/parser.cc (modified) (1 diff)
-
Parser/parser.yy (modified) (2 diffs)
-
main.cc (modified) (9 diffs)
-
tests/.expect/32/gccExtensions.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r7a5d773 r6643e72 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 11:08:56201613 // Update Count : 1 8012 // Last Modified On : Tue Aug 16 18:00:34 2016 13 // Update Count : 179 14 14 // 15 15 … … 780 780 781 781 DeclarationNode *DeclarationNode::appendList( DeclarationNode *node ) { 782 return (DeclarationNode *)set_last( node ); 782 if ( node != 0 ) { 783 set_last( node ); 784 } // if 785 return this; 783 786 } 784 787 -
src/Parser/LinkageSpec.cc
r7a5d773 r6643e72 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:22:09 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Aug 1 7 23:02:37 201613 // Update Count : 1111 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 19 15:53:05 2015 13 // Update Count : 5 14 14 // 15 15 … … 31 31 32 32 std::string LinkageSpec::toString( LinkageSpec::Type linkage ) { 33 static const char *linkageKinds[LinkageSpec::NoOfTypes] = { 34 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", 35 }; 36 return linkageKinds[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 ""; 37 47 } 38 48 39 49 bool LinkageSpec::isDecoratable( Type t ) { 40 static bool decoratable[LinkageSpec::NoOfTypes] = { 41 // Intrinsic, Cforall, C, AutoGen, Compiler 42 true, true, false, true, false, 43 }; 44 return decoratable[ 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; 45 61 } 46 62 47 63 bool LinkageSpec::isGeneratable( Type t ) { 48 static bool generatable[LinkageSpec::NoOfTypes] = { 49 // Intrinsic, Cforall, C, AutoGen, Compiler 50 true, true, true, true, false, 51 }; 52 return generatable[ 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; 53 75 } 54 76 … … 59 81 60 82 bool LinkageSpec::isOverridable( Type t ) { 61 static bool overridable[LinkageSpec::NoOfTypes] = { 62 // Intrinsic, Cforall, C, AutoGen, Compiler 63 true, false, false, true, false, 64 }; 65 return overridable[ 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; 66 94 } 67 95 68 96 bool LinkageSpec::isBuiltin( Type t ) { 69 static bool builtin[LinkageSpec::NoOfTypes] = { 70 // Intrinsic, Cforall, C, AutoGen, Compiler 71 true, false, false, false, true, 72 }; 73 return builtin[ 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; 74 108 } 75 109 -
src/Parser/LinkageSpec.h
r7a5d773 r6643e72 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Aug 17 22:19:48 201613 // Update Count : 611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Aug 18 14:11:55 2015 13 // Update Count : 5 14 14 // 15 15 … … 25 25 C, // not overloadable, not mangled 26 26 AutoGen, // built by translator (struct assignment) 27 Compiler, // gcc internal 28 NoOfTypes 27 Compiler // gcc internal 29 28 }; 30 29 -
src/Parser/parser.cc
r7a5d773 r6643e72 7801 7801 #line 1993 "parser.yy" 7802 7802 { 7803 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall"7803 linkageStack.push( linkage ); 7804 7804 linkage = LinkageSpec::fromString( *(yyvsp[(2) - (2)].tok) ); 7805 7805 } -
src/Parser/parser.yy
r7a5d773 r6643e72 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 11:18:40201613 // Update Count : 190 812 // Last Modified On : Tue Aug 16 21:59:35 2016 13 // Update Count : 1907 14 14 // 15 15 … … 1992 1992 | EXTERN STRINGliteral 1993 1993 { 1994 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall"1994 linkageStack.push( linkage ); 1995 1995 linkage = LinkageSpec::fromString( *$2 ); 1996 1996 } -
src/main.cc
r7a5d773 r6643e72 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 22:13:38201613 // Update Count : 34112 // Last Modified On : Wed Aug 17 09:08:43 2016 13 // Update Count : 274 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) #str75 #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.h81 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 assertf88 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 //************************************************97 72 98 73 int main( int argc, char * argv[] ) { 99 FILE * input; // use FILE rather than istream because yyin is FILE74 FILE * input; 100 75 std::ostream *output = & std::cout; 101 76 std::list< Declaration * > translationUnit; … … 106 81 try { 107 82 // choose to read the program from a file or stdin 108 if ( optind < argc ) { // any commands after the flags ? => input file name83 if ( optind < argc ) { 109 84 input = fopen( argv[ optind ], "r" ); 110 assertf( input, "cannot open %s\n", argv[ optind ] ); 85 if ( ! input ) { 86 std::cout << "Error: cannot open " << argv[ optind ] << std::endl; 87 exit( EXIT_FAILURE ); 88 } // if 111 89 // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to) 112 90 if ( filename == nullptr ) filename = argv[ optind ]; … … 114 92 if ( libcfap ) filename = "prelude.cf"; 115 93 optind += 1; 116 } else { // no input file name94 } else { 117 95 input = stdin; 118 96 // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass … … 121 99 } // if 122 100 123 if ( optind < argc ) { // any commands after the flags and input file ? => output file name101 if ( optind < argc ) { 124 102 output = new ofstream( argv[ optind ] ); 125 103 } // if … … 129 107 // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here. 130 108 FILE * builtins = fopen( libcfap | treep ? "builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" ); 131 assertf( builtins, "cannot open builtins.cf\n" ); 109 if ( builtins == nullptr ) { 110 std::cerr << "Error: cannot open builtins.cf" << std::endl; 111 exit( EXIT_FAILURE ); 112 } // if 132 113 parse( builtins, LinkageSpec::Compiler ); 133 114 134 115 // read the extra prelude in, if not generating the cfa library 135 116 FILE * extras = fopen( libcfap | treep ? "extras.cf" : CFA_LIBDIR "/extras.cf", "r" ); 136 assertf( extras, "cannot open extras.cf\n" ); 117 if ( extras == nullptr ) { 118 std::cerr << "Error: cannot open extras.cf" << std::endl; 119 exit( EXIT_FAILURE ); 120 } // if 137 121 parse( extras, LinkageSpec::C ); 138 122 … … 140 124 // read the prelude in, if not generating the cfa library 141 125 FILE * prelude = fopen( treep ? "prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" ); 142 assertf( prelude, "cannot open prelude.cf\n" ); 126 if ( prelude == nullptr ) { 127 std::cerr << "Error: cannot open prelude.cf" << std::endl; 128 exit( EXIT_FAILURE ); 129 } // if 130 143 131 parse( prelude, LinkageSpec::Intrinsic ); 144 132 } // if … … 367 355 break; 368 356 case '?': 369 assertf( false, "Unknown option: '%c'\n", (char)optopt ); 357 cout << "Unknown option: '" << (char)optopt << "'" << endl; 358 exit( EXIT_FAILURE ); 370 359 default: 371 360 abort(); … … 408 397 } // dump 409 398 410 411 412 399 // Local Variables: // 413 400 // tab-width: 4 // -
src/tests/.expect/32/gccExtensions.txt
r7a5d773 r6643e72 11 11 asm ( "nop" : : : ); 12 12 static int __y__i_2; 13 static int *__z__Pi_2;14 13 int __src__i_2; 15 14 int __dst__i_2; … … 24 23 const int __i2__Ci_2; 25 24 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;36 25 __extension__ const int __ex__Ci_2; 37 26 struct S { … … 84 73 ((void)(__extension__ __a__i_2=(__extension__ __b__i_2+__extension__ __c__i_2))); 85 74 ((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; 86 85 int __a1__i_2; 87 86 const int __a2__Ci_2;
Note:
See TracChangeset
for help on using the changeset viewer.