http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60522

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
BLOCK constructs are not allowed inside WHERE constructs.
Thus, the "common function optimization" should not create a BLOCK to hold the
temporary variables, at least not inside WHERE.

Another possible fix, the following patch disables the optimization inside
WHERE.

diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 52bd700..dc641de 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -630,9 +630,16 @@ static int
 cfe_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
       void *data ATTRIBUTE_UNUSED)
 {
-  current_code = c;
-  inserted_block = NULL;
-  changed_statement = NULL;
+  /* BLOCK constructs cannot appear inside WHERE blocks; as the optimization
+     may introduce the former we disable it inside the latter.  */
+  if ((*c)->op == EXEC_WHERE)
+    *walk_subtrees = 0;
+  else
+    {
+      current_code = c;
+      inserted_block = NULL;
+      changed_statement = NULL;
+    }
   return 0;
 }

Reply via email to