This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Resolution fixes


We currently report failure when asked to simplify things we don't handle 
yet. This isn't a total failure as it only means that such expressions 
won't be reduced to a constant. This will be detected elsewhere if it 
matters.

A resolution failuse should idnicate invalid source, and already have thrown 
an error. I've changed the inimplemented paths to return success.

This uncovered further errors made when calculating the shape of array 
constructors. We were using elements of a constructor before they had been 
resolved. This is also fixed by the attached patch.

Tested on i686-linux.
Applied to tree-ssa branch.

Paul

2003-11-24  Paul Brook  <paul@nowt.org>

	* expr.c (simplify_const_ref): Return SUCCESS for things we don't
	handle.
	* resolve.c (gfc_resolve_expr): Resolve contents before rank/shape.


diff -urpxCVS clean/tree-ssa/gcc/fortran/expr.c gcc/gcc/fortran/expr.c
--- clean/tree-ssa/gcc/fortran/expr.c	2003-08-02 01:25:05.000000000 +0100
+++ gcc/gcc/fortran/expr.c	2003-11-24 18:49:10.000000000 +0000
@@ -932,7 +932,7 @@ simplify_const_ref (gfc_expr * p)
 	      if (p->ref->next != NULL)
 		{
 		  /* TODO: Simplify array subobject references.  */
-		  return FAILURE;
+		  return SUCCESS;
 		}
 		gfc_free_ref_list (p->ref);
 		p->ref = NULL;
@@ -940,7 +940,7 @@ simplify_const_ref (gfc_expr * p)
 
 	    default:
 	      /* TODO: Simplify array subsections.  */
-	      return FAILURE;
+	      return SUCCESS;
 	    }
 
 	  break;
@@ -952,7 +952,7 @@ simplify_const_ref (gfc_expr * p)
 
 	case REF_SUBSTRING:
 	  /* TODO: Constant substrings.  */
-	  return FAILURE;
+	  return SUCCESS;
 	}
     }
 
@@ -1039,7 +1039,8 @@ simplify_parameter_variable (gfc_expr * 
      0   Basic expression parsing
      1   Simplifying array constructors -- will substitute
          iterator values.
-   Returns FAILURE on error, SUCCESS otherwise.  */
+   Returns FAILURE on error, SUCCESS otherwise.
+   NOTE: Will return SUCCESS even if the expression can not be simplified.  */
 
 try
 gfc_simplify_expr (gfc_expr * p, int type)
diff -urpxCVS clean/tree-ssa/gcc/fortran/resolve.c gcc/gcc/fortran/resolve.c
--- clean/tree-ssa/gcc/fortran/resolve.c	2003-11-13 20:22:23.000000000 +0000
+++ gcc/gcc/fortran/resolve.c	2003-11-24 20:00:27.000000000 +0000
@@ -2017,12 +2017,13 @@ gfc_resolve_expr (gfc_expr * e)
       if (resolve_ref (e) == FAILURE)
 	break;
 
-      expression_rank (e);
-
       t = gfc_resolve_array_constructor (e);
       /* Also try to expand a constructor.  */
       if (t == SUCCESS)
-	gfc_expand_constructor (e);
+	{
+	  expression_rank (e);
+	  gfc_expand_constructor (e);
+	}
 
       break;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]