[Prev][Next][Index]

pb with fortran else if and insertStatementBefore




hello,

It looks insertStatementBefore or replaceWithStatement is
confused with the fortran else if statement.
for example I applied the following program :

...
    case PROC_STAT:
      cout << "!!!! CALL ROUTINE SYMBOL = " << s->symbol()->identifier() << " \n";

      SgCallStmt     *aFunCall;
      SgSymbol       *aSymbol;
      SgValueExp     zero (0);

      aSymbol  = new SgSymbol (PROCEDURE_NAME, "dupont");
      aFunCall = new SgCallStmt(* aSymbol);
      aFunCall->addArg (zero);
      s->insertStmtBefore (* aFunCall);
//      s->replaceWithStmt (* aFunCall);
      
...

on the following test fortran program :

      program toto
      
      integer info, m

      read *,m
      if( m .lt. 0 ) then
         print*,' m =',m
      else if( m .eq. 0 ) then
         goto 300
      else
         CALL albert (info )
         if( info .lt. 0 ) then
            print *,'Error = ',info
         endif
      endif
      end

and I got this output :

!!!! CALL ROUTINE SYMBOL = albert 
      program toto
      integer  info,m
      read (unit = *, fmt = *)m
      if (m .lt. 0) then 
          print *,' m =',m
        else if (m .eq. 0) then
            goto 300
          else
            call albert(info)
            if (info .lt. 0) then 
                print *,'Error = ',info
             endif
         call dupont(0)
      endif
      end

I remplace the insertStmtBefore by remplaceStmtWith and I got
this output:

!!!! CALL ROUTINE SYMBOL = albert 
      program toto
      integer  info,m
      read (unit = *, fmt = *)m
      if (m .lt. 0) then 
          print *,' m =',m
        else if (m .eq. 0) then
            goto 300
            call dupont(0)
          else
            if (info .lt. 0) then 
                print *,'Error = ',info
             endif
      endif
      end

Any idea about it ?


S. Yhuel

+---------------------------------------------------------------------+
Stephane YHUEL (Scientifique du contingent)   
ONERA DI          Calcul Parallele   "E-mail" : yhuel@onera.fr   
29,  Avenue de la Division Leclerc   Telecopie: +33 (1) 46 73 43 83 
BP 72 92322 Chatillon Cedex FRANCE   Telephone: +33 (1) 46 73 40 40 
+---------------------------------------------------------------------+