Changes in / [7a5d773:6643e72]


Ignore:
Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r7a5d773 r6643e72  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 11:08:56 2016
    13 // Update Count     : 180
     12// Last Modified On : Tue Aug 16 18:00:34 2016
     13// Update Count     : 179
    1414//
    1515
     
    780780
    781781DeclarationNode *DeclarationNode::appendList( DeclarationNode *node ) {
    782         return (DeclarationNode *)set_last( node );
     782        if ( node != 0 ) {
     783                set_last( node );
     784        } // if
     785        return this;
    783786}
    784787
  • src/Parser/LinkageSpec.cc

    r7a5d773 r6643e72  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:22:09 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 23:02:37 2016
    13 // Update Count     : 11
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 19 15:53:05 2015
     13// Update Count     : 5
    1414//
    1515
     
    3131
    3232std::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 "";
    3747}
    3848
    3949bool 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;
    4561}
    4662
    4763bool 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;
    5375}
    5476
     
    5981
    6082bool 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;
    6694}
    6795
    6896bool 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;
    74108}
    75109
  • src/Parser/LinkageSpec.h

    r7a5d773 r6643e72  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 22:19:48 2016
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Aug 18 14:11:55 2015
     13// Update Count     : 5
    1414//
    1515
     
    2525                C,                                                                                              // not overloadable, not mangled
    2626                AutoGen,                                                                                // built by translator (struct assignment)
    27                 Compiler,                                                                               // gcc internal
    28                 NoOfTypes
     27                Compiler                                                                                // gcc internal
    2928        };
    3029 
  • src/Parser/parser.cc

    r7a5d773 r6643e72  
    78017801#line 1993 "parser.yy"
    78027802    {
    7803                         linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     7803                        linkageStack.push( linkage );
    78047804                        linkage = LinkageSpec::fromString( *(yyvsp[(2) - (2)].tok) );
    78057805                }
  • src/Parser/parser.yy

    r7a5d773 r6643e72  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 11:18:40 2016
    13 // Update Count     : 1908
     12// Last Modified On : Tue Aug 16 21:59:35 2016
     13// Update Count     : 1907
    1414//
    1515
     
    19921992        | EXTERN STRINGliteral
    19931993                {
    1994                         linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     1994                        linkageStack.push( linkage );
    19951995                        linkage = LinkageSpec::fromString( *$2 );
    19961996                }
  • src/main.cc

    r7a5d773 r6643e72  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 22:13:38 2016
    13 // Update Count     : 341
     12// Last Modified On : Wed Aug 17 09:08:43 2016
     13// Update Count     : 274
    1414//
    1515
     
    7070static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout );
    7171
    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 //************************************************
    9772
    9873int main( int argc, char * argv[] ) {
    99         FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
     74        FILE * input;
    10075        std::ostream *output = & std::cout;
    10176        std::list< Declaration * > translationUnit;
     
    10681        try {
    10782                // choose to read the program from a file or stdin
    108                 if ( optind < argc ) {                                                  // any commands after the flags ? => input file name
     83                if ( optind < argc ) {
    10984                        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
    11189                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
    11290                        if ( filename == nullptr ) filename = argv[ optind ];
     
    11492                        if ( libcfap ) filename = "prelude.cf";
    11593                        optind += 1;
    116                 } else {                                                                                // no input file name
     94                } else {
    11795                        input = stdin;
    11896                        // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
     
    12199                } // if
    122100
    123                 if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
     101                if ( optind < argc ) {
    124102                        output = new ofstream( argv[ optind ] );
    125103                } // if
     
    129107                        // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here.
    130108                        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
    132113                        parse( builtins, LinkageSpec::Compiler );
    133114
    134115                        // read the extra prelude in, if not generating the cfa library
    135116                        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
    137121                        parse( extras, LinkageSpec::C );
    138122
     
    140124                                // read the prelude in, if not generating the cfa library
    141125                                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
    143131                                parse( prelude, LinkageSpec::Intrinsic );
    144132                        } // if
     
    367355                        break;
    368356                  case '?':
    369                         assertf( false, "Unknown option: '%c'\n", (char)optopt );
     357                        cout << "Unknown option: '" << (char)optopt << "'" << endl;
     358                        exit( EXIT_FAILURE );
    370359                  default:
    371360                        abort();
     
    408397} // dump
    409398
    410 
    411 
    412399// Local Variables: //
    413400// tab-width: 4 //
  • src/tests/.expect/32/gccExtensions.txt

    r7a5d773 r6643e72  
    1111    asm ( "nop" :  :  :  );
    1212    static int __y__i_2;
    13     static int *__z__Pi_2;
    1413    int __src__i_2;
    1514    int __dst__i_2;
     
    2423    const int __i2__Ci_2;
    2524    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;
    3625    __extension__ const int __ex__Ci_2;
    3726    struct S {
     
    8473    ((void)(__extension__ __a__i_2=(__extension__ __b__i_2+__extension__ __c__i_2)));
    8574    ((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;
    8685    int __a1__i_2;
    8786    const int __a2__Ci_2;
Note: See TracChangeset for help on using the changeset viewer.