diff -cr gcc/fortran/dump-parse-tree.c gcc.patched/gcc/fortran/dump-parse-tree.c
*** gcc/fortran/dump-parse-tree.c	2008-09-02 10:13:21.000000000 +0200
--- gcc.patched/gcc/fortran/dump-parse-tree.c	2010-04-20 21:35:22.770964102 +0200
***************
*** 42,48 ****
  static FILE *dumpfile;
  
  /* Forward declaration of some of the functions.  */
! static void show_expr (gfc_expr *p);
  static void show_code_node (int, gfc_code *);
  static void show_namespace (gfc_namespace *ns);
  
--- 42,48 ----
  static FILE *dumpfile;
  
  /* Forward declaration of some of the functions.  */
! void show_expr (gfc_expr *p);
  static void show_code_node (int, gfc_code *);
  static void show_namespace (gfc_namespace *ns);
  
***************
*** 334,340 ****
  
  /* Show an expression.  */
  
! static void
  show_expr (gfc_expr *p)
  {
    const char *c;
--- 334,340 ----
  
  /* Show an expression.  */
  
! void
  show_expr (gfc_expr *p)
  {
    const char *c;
***************
*** 2045,2050 ****
  void
  gfc_dump_parse_tree (gfc_namespace *ns, FILE *file)
  {
!   dumpfile = file;
!   show_namespace (ns);
  }
--- 2045,2051 ----
  void
  gfc_dump_parse_tree (gfc_namespace *ns, FILE *file)
  {
!   dumpfile = stderr;
! //  show_namespace (ns);
!   gfc2pips_namespace( ns ); // Entry point for GFC2PIPS 
  }
Seulement dans gcc.patched/gcc/fortran: gfc2pips.c
Seulement dans gcc.patched/gcc/fortran: gfc2pips.h
Seulement dans gcc.patched/gcc/fortran: gfc2pips-private.h
Seulement dans gcc.patched/gcc/fortran: gfc2pips_stubs.c
diff -cr gcc/fortran/gfortran.h gcc.patched/gcc/fortran/gfortran.h
*** gcc/fortran/gfortran.h	2009-02-21 23:25:06.000000000 +0100
--- gcc.patched/gcc/fortran/gfortran.h	2010-04-20 21:35:22.780964675 +0200
***************
*** 230,236 ****
    ST_OMP_PARALLEL_WORKSHARE, ST_OMP_SECTIONS, ST_OMP_SECTION, ST_OMP_SINGLE,
    ST_OMP_THREADPRIVATE, ST_OMP_WORKSHARE, ST_OMP_TASK, ST_OMP_END_TASK,
    ST_OMP_TASKWAIT, ST_PROCEDURE, ST_GENERIC,
!   ST_GET_FCN_CHARACTERISTICS, ST_NONE
  }
  gfc_statement;
  
--- 230,236 ----
    ST_OMP_PARALLEL_WORKSHARE, ST_OMP_SECTIONS, ST_OMP_SECTION, ST_OMP_SINGLE,
    ST_OMP_THREADPRIVATE, ST_OMP_WORKSHARE, ST_OMP_TASK, ST_OMP_END_TASK,
    ST_OMP_TASKWAIT, ST_PROCEDURE, ST_GENERIC,
!   ST_GET_FCN_CHARACTERISTICS, ST_NONE, ST_COMMENTS
  }
  gfc_statement;
  
***************
*** 2033,2038 ****
--- 2033,2040 ----
    int convert;
    int record_marker;
    int max_subrecord_length;
+ 
+   const char *gfc2pips_entities;
  }
  gfc_option_t;
  
diff -cr gcc/fortran/lang.opt gcc.patched/gcc/fortran/lang.opt
*** gcc/fortran/lang.opt	2009-03-18 22:14:53.000000000 +0100
--- gcc.patched/gcc/fortran/lang.opt	2010-04-20 21:35:22.780964675 +0200
***************
*** 68,73 ****
--- 68,77 ----
  Fortran
  ; Documented in C
  
+ pips-entities
+ Fortran Separate
+ ; Documented in C
+ 
  Waliasing
  Fortran Warning
  Warn about possible aliasing of dummy arguments
diff -cr gcc/fortran/Make-lang.in gcc.patched/gcc/fortran/Make-lang.in
*** gcc/fortran/Make-lang.in	2008-12-11 12:29:38.000000000 +0100
--- gcc.patched/gcc/fortran/Make-lang.in	2010-04-20 21:40:15.000000000 +0200
***************
*** 95,104 ****
  	cp gfortran$(exeext) gfortran-cross$(exeext)
  
  # The compiler itself is called f951.
! f951$(exeext): $(F95_OBJS) \
! 		$(BACKEND) $(LIBDEPS) attribs.o
! 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
! 		$(F95_OBJS) $(BACKEND) $(LIBS) attribs.o $(BACKENDLIBS)
  
  gt-fortran-trans.h    : s-gtype; @true
  #
--- 95,102 ----
  	cp gfortran$(exeext) gfortran-cross$(exeext)
  
  # The compiler itself is called f951.
! include ../../../$(pipssrcdir)/gfc2pips$(GFC2PIPS-AUTOTOOL-MAKEFILE).mk
! include ../../../$(pipssrcdir)/gfc2pips-common.mk
  
  gt-fortran-trans.h    : s-gtype; @true
  #
diff -cr gcc/fortran/module.c gcc.patched/gcc/fortran/module.c
*** gcc/fortran/module.c	2009-05-22 14:54:23.000000000 +0200
--- gcc.patched/gcc/fortran/module.c	2010-04-20 21:35:22.790990880 +0200
***************
*** 487,492 ****
--- 487,493 ----
      }
  }
  
+ void gfc2pips_get_use_st( void );
  
  /* Match a USE statement.  */
  
***************
*** 502,507 ****
--- 503,511 ----
    specified_int = false;
    specified_nonint = false;
  
+ 
+   gfc2pips_get_use_st();
+ 
    if (gfc_match (" , ") == MATCH_YES)
      {
        if ((m = gfc_match (" %n ::", module_nature)) == MATCH_YES)
diff -cr gcc/fortran/options.c gcc.patched/gcc/fortran/options.c
*** gcc/fortran/options.c	2008-11-03 08:20:24.000000000 +0100
--- gcc.patched/gcc/fortran/options.c	2010-04-20 21:35:22.790990880 +0200
***************
*** 123,128 ****
--- 123,129 ----
    gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
    gfc_option.flag_init_character_value = (char)0;
    gfc_option.flag_align_commons = 1;
+   gfc_option.gfc2pips_entities = 0;
    
    gfc_option.fpe = 0;
  
***************
*** 743,748 ****
--- 744,753 ----
  			 "between 0 and 127");
        break;
  
+     case OPT_pips_entities :
+       gfc_option.gfc2pips_entities = arg;
+       break;
+ 
      case OPT_I:
        gfc_add_include_path (arg, true, false);
        break;
diff -cr gcc/fortran/parse.c gcc.patched/gcc/fortran/parse.c
*** gcc/fortran/parse.c	2009-04-04 15:19:15.000000000 +0200
--- gcc.patched/gcc/fortran/parse.c	2010-04-20 21:35:22.800994735 +0200
***************
*** 27,32 ****
--- 27,38 ----
  #include "parse.h"
  #include "debug.h"
  
+ #include "gfc2pips.h"
+ 
+ int gfc2pips_nb_of_statements = 1;
+ gfc2pips_comments gfc2pips_comments_stack;
+ gfc2pips_comments gfc2pips_comments_stack_;
+ 
  /* Current statement label.  Zero means no statement label.  Because new_st
     can get wiped during statement matching, we have to keep it separate.  */
  
***************
*** 807,812 ****
--- 813,821 ----
    locus old_locus;
    gfc_new_block = NULL;
  
+ 
+   gfc2pips_set_last_comments_done(gfc2pips_nb_of_statements);
+ 
    gfc_current_ns->old_cl_list = gfc_current_ns->cl_list;
    for (;;)
      {
***************
*** 920,925 ****
--- 929,935 ----
  pop_state (void)
  {
    gfc_state_stack = gfc_state_stack->previous;
+   gfc2pips_pop_not_done_comments();
  }
  
  
***************
*** 1443,1448 ****
--- 1453,1459 ----
  static void
  accept_statement (gfc_statement st)
  {
+ 	gfc2pips_nb_of_statements++;
    switch (st)
      {
      case ST_USE:
***************
*** 2622,2630 ****
    gfc_statement st;
    locus else_locus;
    gfc_state_data s;
!   int seen_else;
  
!   seen_else = 0;
    accept_statement (ST_IF_BLOCK);
  
    top = gfc_state_stack->tail;
--- 2633,2641 ----
    gfc_statement st;
    locus else_locus;
    gfc_state_data s;
!   int seen_else,seen_elseif;
  
!   seen_elseif = seen_else = 0;
    accept_statement (ST_IF_BLOCK);
  
    top = gfc_state_stack->tail;
***************
*** 2636,2642 ****
    d->expr = top->expr;
    top->expr = NULL;
    top->block = d;
! 
    do
      {
        st = parse_executable (ST_NONE);
--- 2647,2658 ----
    d->expr = top->expr;
    top->expr = NULL;
    top->block = d;
!   //make appear the first comment of a if block if there are several instructions in the block
!   gfc2pips_replace_comments_num(gfc2pips_nb_of_statements-1,gfc2pips_nb_of_statements);
!   gfc2pips_nb_of_statements++;
!   //we still have a problem if there only is one instruction
!   unsigned long current_num = gfc2pips_nb_of_statements;
!   fprintf(stderr,"gfc2pips_nb_of_statements: begin %d\n",gfc2pips_nb_of_statements);
    do
      {
        st = parse_executable (ST_NONE);
***************
*** 2656,2661 ****
--- 2672,2678 ----
  	      break;
  	    }
  
+ 	  seen_elseif = 1;
  	  d = new_level (gfc_state_stack->head);
  	  d->op = EXEC_IF;
  	  d->expr = new_st.expr;
***************
*** 2693,2698 ****
--- 2710,2722 ----
      }
    while (st != ST_ENDIF);
  
+   //fprintf(stderr,"gfc2pips_nb_of_statements: near end %d\n",gfc2pips_nb_of_statements);
+   //see the right combination of seen_else and seen_elseif
+   if( seen_elseif || seen_else ) gfc2pips_nb_of_statements-=2;
+   if( seen_elseif && !seen_else ) gfc2pips_nb_of_statements++;
+   if( !seen_elseif && !seen_else ) gfc2pips_nb_of_statements--;
+   //fprintf(stderr,"gfc2pips_nb_of_statements: end %d\n",gfc2pips_nb_of_statements);
+ 
    pop_state ();
    accept_statement (st);
  }
***************
*** 3744,3749 ****
--- 3768,3774 ----
    gfc_statement st;
    locus prog_locus;
  
+   gfc2pips_comments_stack = NULL;
    gfc_start_source_files ();
  
    top.state = COMP_NONE;
diff -cr gcc/fortran/scanner.c gcc.patched/gcc/fortran/scanner.c
*** gcc/fortran/scanner.c	2009-02-20 16:20:38.000000000 +0100
--- gcc.patched/gcc/fortran/scanner.c	2010-04-20 21:35:22.810962622 +0200
***************
*** 48,53 ****
--- 48,55 ----
  #include "debug.h"
  #include "flags.h"
  #include "cpp.h"
+ #include "gfc2pips.h"
+ 
  
  /* Structure for holding module and include file search path.  */
  typedef struct gfc_directorylist
***************
*** 806,811 ****
--- 808,814 ----
  
        if (c == '!' || c == 'c' || c == 'C' || c == '*')
  	{
+           gfc2pips_push_comment(gfc_current_locus,gfc2pips_nb_of_statements,c);
  	  /* If -fopenmp, we need to handle here 2 things:
  	     1) don't treat !$omp|c$omp|*$omp as comments, but directives
  	     2) handle OpenMP conditional compilation, where
diff -cr gcc/fortran/st.c gcc.patched/gcc/fortran/st.c
*** gcc/fortran/st.c	2008-08-31 12:00:30.000000000 +0200
--- gcc.patched/gcc/fortran/st.c	2010-04-20 21:35:22.810962622 +0200
***************
*** 50,55 ****
--- 50,59 ----
  
    c = XCNEW (gfc_code);
    c->loc = gfc_current_locus;
+ 
+   gfc2pips_push_last_code(c);
+   gfc2pips_assign_gfc_code_to_last_comments(c);
+ 
    return c;
  }
  
