Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    rbec4d24 rbf71cfd  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  3 16:57:05 2018
    13 // Update Count     : 125
     12// Last Modified On : Thu Jul 19 10:46:11 2018
     13// Update Count     : 111
    1414//
    1515
     
    3232string compiler_name( CFA_BACKEND_CC );                                 // path/name of C compiler
    3333
     34string D__GCC_X__( "-D__GCC_X__=" );
    3435string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" );
    3536string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
     
    4647const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    4748
    48 void suffix( string arg, const char * args[], int & nargs ) {
     49bool suffix( string arg ) {
    4950        //std::cerr << arg << std::endl;
    5051        size_t dot = arg.find_last_of( "." );
    5152        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    52         if ( dot == string::npos ) return;
     53        if ( dot == string::npos ) return false;
    5354        string sx = arg.substr( dot + 1 );
    5455        for ( int i = 0; i < NumSuffixes; i += 1 ) {
    55                 if ( sx == suffixes[i] ) {
    56                         args[nargs] = "-x";
    57                         nargs += 1;
    58                         args[nargs] = "c";
    59                         nargs += 1;
    60                         return;
    61                 } // if
    62         } // for
     56                if ( sx == suffixes[i] ) return true;
     57        } // for
     58        return false;
    6359} // suffix
    6460
    6561
    66 void checkEnv( const char * args[], int & nargs ) {
     62void checkEnv( const char *args[], int &nargs ) {
    6763        char *value;
    6864
    69         value = getenv( "__CFA_COMPILER__" );
     65        value = getenv( "__COMPILER__" );
    7066        if ( value != NULL ) {
    7167                compiler_name = value;
     
    114110void Stage1( const int argc, const char * const argv[] ) {
    115111        int code;
     112        int i;
    116113
    117114        string arg;
     
    136133        cerr << "Stage1" << endl;
    137134        #endif // __DEBUG_H__
     135
     136        // process all the arguments
     137
    138138        checkEnv( args, nargs );                                                        // arguments passed via environment variables
    139         #ifdef __DEBUG_H__
    140         for ( int i = 1; i < argc; i += 1 ) {
     139
     140        for ( i = 1; i < argc; i += 1 ) {
     141                #ifdef __DEBUG_H__
    141142                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    142         } // for
    143         #endif // __DEBUG_H__
    144 
    145         // process all the arguments
    146 
    147         for ( int i = 1; i < argc; i += 1 ) {
     143                #endif // __DEBUG_H__
    148144                arg = argv[i];
     145                #ifdef __DEBUG_H__
     146                cerr << "arg:\"" << arg << "\"" << endl;
     147                #endif // __DEBUG_H__
    149148                if ( prefix( arg, "-" ) ) {
    150149                        // strip g++ flags that are inappropriate or cause duplicates in subsequent passes
     
    180179                                ncargs += 1;
    181180                                i += 1;                                                                 // and the argument
     181                        // } else if ( prefix( arg, D__GCC_X__ ) ) {
     182                        //      args[nargs] = "-x";
     183                        //      nargs += 1;
     184                        //      args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along
     185                        //      nargs += 1;
     186                        // } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) {
     187                        //      args[nargs] = "-x";
     188                        //      nargs += 1;
     189                        //      args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along
     190                        //      nargs += 1;
     191                        //      i += 1;                                                                 // and the argument
    182192                        } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
    183193                                bprefix = arg.substr( D__GCC_BPREFIX__.size() );
     
    235245        #ifdef __DEBUG_H__
    236246        cerr << "args:";
    237         for ( int i = 1; i < nargs; i += 1 ) {
     247        for ( i = 1; i < nargs; i += 1 ) {
    238248                cerr << " " << args[i];
    239249        } // for
     
    253263
    254264                args[0] = compiler_name.c_str();
    255                 suffix( cpp_in, args, nargs );                                  // check suffix
    256265                args[nargs] = cpp_in;
    257266                nargs += 1;
     
    266275                #ifdef __DEBUG_H__
    267276                cerr << "nargs: " << nargs << endl;
    268                 for ( int i = 0; args[i] != NULL; i += 1 ) {
     277                for ( i = 0; args[i] != NULL; i += 1 ) {
    269278                        cerr << args[i] << " ";
    270279                } // for
     
    301310
    302311                args[0] = compiler_name.c_str();
    303                 suffix( cpp_in, args, nargs );                                  // check suffix
     312                if ( suffix( cpp_in ) ) {
     313                        args[nargs] = "-x";
     314                        nargs += 1;
     315                        args[nargs] = "c";
     316                        nargs += 1;
     317                } // if
    304318                args[nargs] = cpp_in;                                                   // input to cpp
    305319                nargs += 1;
     
    308322                #ifdef __DEBUG_H__
    309323                cerr << "cpp nargs: " << nargs << endl;
    310                 for ( int i = 0; args[i] != NULL; i += 1 ) {
     324                for ( i = 0; args[i] != NULL; i += 1 ) {
    311325                        cerr << args[i] << " ";
    312326                } // for
     
    340354
    341355        if ( fork() == 0 ) {                                                            // child runs CFA
    342                 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
     356                cargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
    343357
    344358                // Source file-name used to generate routine names containing global initializations for TU.
     
    361375                #ifdef __DEBUG_H__
    362376                cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl;
    363                 for ( int i = 0; cargs[i] != NULL; i += 1 ) {
     377                for ( i = 0; cargs[i] != NULL; i += 1 ) {
    364378                        cerr << cargs[i] << " ";
    365379                } // for
     
    391405
    392406void Stage2( const int argc, const char * const * argv ) {
     407        int i;
     408
    393409        string arg;
    394410
     
    401417        cerr << "Stage2" << endl;
    402418        #endif // __DEBUG_H__
     419
     420        // process all the arguments
     421
    403422        checkEnv( args, nargs );                                                        // arguments passed via environment variables
    404         #ifdef __DEBUG_H__
    405         for ( int i = 1; i < argc; i += 1 ) {
     423
     424        for ( i = 1; i < argc; i += 1 ) {
     425                #ifdef __DEBUG_H__
    406426                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    407         } // for
    408         #endif // __DEBUG_H__
    409 
    410         // process all the arguments
    411 
    412         for ( int i = 1; i < argc; i += 1 ) {
     427                #endif // __DEBUG_H__
    413428                arg = argv[i];
     429                #ifdef __DEBUG_H__
     430                cerr << "arg:\"" << arg << "\"" << endl;
     431                #endif // __DEBUG_H__
    414432                if ( prefix( arg, "-" ) ) {
    415433                        // strip inappropriate flags
     
    456474        #ifdef __DEBUG_H__
    457475        cerr << "args:";
    458         for ( int i = 1; i < nargs; i += 1 ) {
     476        for ( i = 1; i < nargs; i += 1 ) {
    459477                cerr << " " << args[i];
    460478        } // for
     
    472490        #ifdef __DEBUG_H__
    473491        cerr << "stage2 nargs: " << nargs << endl;
    474         for ( int i = 0; args[i] != NULL; i += 1 ) {
     492        for ( i = 0; args[i] != NULL; i += 1 ) {
    475493                cerr << args[i] << " ";
    476494        } // for
     
    486504int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    487505        #ifdef __DEBUG_H__
    488         for ( int int i = 0; env[i] != NULL; i += 1 ) {
     506        for ( int i = 0; env[i] != NULL; i += 1 ) {
    489507                cerr << env[i] << endl;
    490508        } // for
Note: See TracChangeset for help on using the changeset viewer.