Re: [patch, fortran] PR 48405 - Front end expressions in DO loops

2011-04-21 Thread Thomas Koenig

Am 19.04.2011 20:35, schrieb Thomas Koenig:

Hello world,

this patch fixes the enhancement PR, plus probably a few regressions.

The basic problem was that the code walker got confused when *c, the
pointer to the current gfc_code statement, was changed by inserting
additional code.

Currently regression-testing. OK for trunk if the tests pass?


Regression-testing passed.  Ping ** 0.25?

Thomas


Re: [patch, fortran] PR 48405 - Front end expressions in DO loops

2011-04-21 Thread Mikael Morin
On Thursday 21 April 2011 16:02:18 Thomas Koenig wrote:
 Am 19.04.2011 20:35, schrieb Thomas Koenig:
  Hello world,
  
  this patch fixes the enhancement PR, plus probably a few regressions.
  
  The basic problem was that the code walker got confused when *c, the
  pointer to the current gfc_code statement, was changed by inserting
  additional code.
  
  Currently regression-testing. OK for trunk if the tests pass?
 
 Regression-testing passed.  Ping ** 0.25?
 
   Thomas

OK. Thanks

Mikael



Re: [patch, fortran] PR 48405 - Front end expressions in DO loops

2011-04-21 Thread Thomas Koenig

Hi Mikael,


Regression-testing passed.  Ping ** 0.25?

Thomas


OK. Thanks



Waiting for Emacs...
Sende  fortran/ChangeLog
Sende  fortran/frontend-passes.c
Sende  testsuite/ChangeLog
Hinzufügen testsuite/gfortran.dg/function_optimize_6.f90
Übertrage Daten 
Revision 172838 übertragen.

Thanks for the review!

Thomas


[patch, fortran] PR 48405 - Front end expressions in DO loops

2011-04-19 Thread Thomas Koenig

Hello world,

this patch fixes the enhancement PR, plus probably a few regressions.

The basic problem was that the code walker got confused when *c, the 
pointer to the current gfc_code statement, was changed by inserting 
additional code.


Currently regression-testing. OK for trunk if the tests pass?

Thomas

2011-04-18  Thomas Koenig  tkoe...@gcc.gnu.org

PR fortran/48405
* frontend_passes (cfe_register_funcs): Remove workaround for DO
loops.
(gfc_code_walker):  Make sure the pointer to the current
statement doen't change when other statements are inserted.

2011-04-18  Thomas Koenig  tkoe...@gcc.gnu.org

PR fortran/48405
* gfortran.dg/function_optimize_6.f90:  New test.
Index: frontend-passes.c
===
--- frontend-passes.c	(Revision 172607)
+++ frontend-passes.c	(Arbeitskopie)
@@ -142,12 +142,6 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtre
 	  void *data ATTRIBUTE_UNUSED)
 {
 
-  /* FIXME - there is a bug in the insertion code for DO loops.  Bail
- out here.  */
-
-  if ((*current_code)-op == EXEC_DO)
-return 0;
-
   if ((*e)-expr_type != EXPR_FUNCTION)
 return 0;
 
@@ -958,31 +952,37 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	{
 	  gfc_code *b;
 	  gfc_actual_arglist *a;
+	  gfc_code *co;
 
-	  switch ((*c)-op)
+	  /* There might be statement insertions before the current code,
+	 which must not affect the expression walker.  */
+
+	  co = *c;
+
+	  switch (co-op)
 	{
 	case EXEC_DO:
-	  WALK_SUBEXPR ((*c)-ext.iterator-var);
-	  WALK_SUBEXPR ((*c)-ext.iterator-start);
-	  WALK_SUBEXPR ((*c)-ext.iterator-end);
-	  WALK_SUBEXPR ((*c)-ext.iterator-step);
+	  WALK_SUBEXPR (co-ext.iterator-var);
+	  WALK_SUBEXPR (co-ext.iterator-start);
+	  WALK_SUBEXPR (co-ext.iterator-end);
+	  WALK_SUBEXPR (co-ext.iterator-step);
 	  break;
 
 	case EXEC_CALL:
 	case EXEC_ASSIGN_CALL:
-	  for (a = (*c)-ext.actual; a; a = a-next)
+	  for (a = co-ext.actual; a; a = a-next)
 		WALK_SUBEXPR (a-expr);
 	  break;
 
 	case EXEC_CALL_PPC:
-	  WALK_SUBEXPR ((*c)-expr1);
-	  for (a = (*c)-ext.actual; a; a = a-next)
+	  WALK_SUBEXPR (co-expr1);
+	  for (a = co-ext.actual; a; a = a-next)
 		WALK_SUBEXPR (a-expr);
 	  break;
 
 	case EXEC_SELECT:
-	  WALK_SUBEXPR ((*c)-expr1);
-	  for (b = (*c)-block; b; b = b-block)
+	  WALK_SUBEXPR (co-expr1);
+	  for (b = co-block; b; b = b-block)
 		{
 		  gfc_case *cp;
 		  for (cp = b-ext.block.case_list; cp; cp = cp-next)
@@ -998,7 +998,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	case EXEC_DEALLOCATE:
 	  {
 		gfc_alloc *a;
-		for (a = (*c)-ext.alloc.list; a; a = a-next)
+		for (a = co-ext.alloc.list; a; a = a-next)
 		  WALK_SUBEXPR (a-expr);
 		break;
 	  }
@@ -1006,7 +1006,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	case EXEC_FORALL:
 	  {
 		gfc_forall_iterator *fa;
-		for (fa = (*c)-ext.forall_iterator; fa; fa = fa-next)
+		for (fa = co-ext.forall_iterator; fa; fa = fa-next)
 		  {
 		WALK_SUBEXPR (fa-var);
 		WALK_SUBEXPR (fa-start);
@@ -1017,110 +1017,110 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	  }
 
 	case EXEC_OPEN:
-	  WALK_SUBEXPR ((*c)-ext.open-unit);
-	  WALK_SUBEXPR ((*c)-ext.open-file);
-	  WALK_SUBEXPR ((*c)-ext.open-status);
-	  WALK_SUBEXPR ((*c)-ext.open-access);
-	  WALK_SUBEXPR ((*c)-ext.open-form);
-	  WALK_SUBEXPR ((*c)-ext.open-recl);
-	  WALK_SUBEXPR ((*c)-ext.open-blank);
-	  WALK_SUBEXPR ((*c)-ext.open-position);
-	  WALK_SUBEXPR ((*c)-ext.open-action);
-	  WALK_SUBEXPR ((*c)-ext.open-delim);
-	  WALK_SUBEXPR ((*c)-ext.open-pad);
-	  WALK_SUBEXPR ((*c)-ext.open-iostat);
-	  WALK_SUBEXPR ((*c)-ext.open-iomsg);
-	  WALK_SUBEXPR ((*c)-ext.open-convert);
-	  WALK_SUBEXPR ((*c)-ext.open-decimal);
-	  WALK_SUBEXPR ((*c)-ext.open-encoding);
-	  WALK_SUBEXPR ((*c)-ext.open-round);
-	  WALK_SUBEXPR ((*c)-ext.open-sign);
-	  WALK_SUBEXPR ((*c)-ext.open-asynchronous);
-	  WALK_SUBEXPR ((*c)-ext.open-id);
-	  WALK_SUBEXPR ((*c)-ext.open-newunit);
+	  WALK_SUBEXPR (co-ext.open-unit);
+	  WALK_SUBEXPR (co-ext.open-file);
+	  WALK_SUBEXPR (co-ext.open-status);
+	  WALK_SUBEXPR (co-ext.open-access);
+	  WALK_SUBEXPR (co-ext.open-form);
+	  WALK_SUBEXPR (co-ext.open-recl);
+	  WALK_SUBEXPR (co-ext.open-blank);
+	  WALK_SUBEXPR (co-ext.open-position);
+	  WALK_SUBEXPR (co-ext.open-action);
+	  WALK_SUBEXPR (co-ext.open-delim);
+	  WALK_SUBEXPR (co-ext.open-pad);
+	  WALK_SUBEXPR (co-ext.open-iostat);
+	  WALK_SUBEXPR (co-ext.open-iomsg);
+	  WALK_SUBEXPR (co-ext.open-convert);
+	  WALK_SUBEXPR (co-ext.open-decimal);
+	  WALK_SUBEXPR (co-ext.open-encoding);
+	  WALK_SUBEXPR