[Patch, Fortran] SELECT TYPE with associate-name

Daniel Kraft d@domob.eu
Mon Oct 5 13:18:00 GMT 2009


Hi Janus!

Janus Weil wrote:
> here is a patch that implements a small enhancement for the SELECT
> TYPE construct, namely using an associate-name, as in:
> 
> SELECT TYPE ( x => ... )
> 
> The dots can be any CLASS-valued expression here, which makes it
> possible to use arbitrary expressions as a selector, and not only
> named variables.
> 
> What I do to accomplish this is basically: Use the associate-name 'x'
> like an ordinary variable, except that it gets its type from the
> selector expression, and insert an additional operation in front of
> the SELECT block which does the assignment "x => ...".
> 
> The patch works fine on the attached test case and also makes
> Salvatore's PSBLAS compile. It was regtested on
> x86_64-unknown-linux-gnu with no failures.
> 
> Ok for trunk?

Ok after considering my comments below and when trunk reopens.

+	  else
+	    gfc_check_pointer_assign (code->expr1, code->expr2);

-	  gfc_check_pointer_assign (code->expr1, code->expr2);

Your Changelog here says you don't want to call check_pointer_assign for 
CLASS assignments; it confuses me a little that you do this as well as 
fix check_pointer_assign to correctly handle CLASS as well.  But I guess 
that's alright and it is called sometimes with CLASS arguments anyways.

    /* Check for F03:C811.
       TODO: Change error message once ASSOCIATE is implemented.  */
-  if (expr->expr_type != EXPR_VARIABLE || expr->ref != NULL)
+  if (expr1->expr_type != EXPR_VARIABLE || expr1->ref != NULL)

That TODO is probably now void, isn't it?  But you didn't change the 
error message, so maybe even not?  Needs this further fixing?

Thanks for your patch!

Daniel

-- 
Done:  Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri



More information about the Gcc-patches mailing list