[PATCH] fortran/20869 -- INTRINSIC and EXTERNAL conflict

THOMAS Paul Richard 169137 paul.richard.thomas@cea.fr
Tue Jan 17 13:38:00 GMT 2006


Steve,

> 
> gfc_match_intrinsic and gfc_match_external work for attributes
> in a single statement, ie.,
> 
> real, intrinsic, external :: x

Yes, indeed.

> 
> will trigger an error.  OTOH, the INTRINSIC and EXTERNAL statements
> do not (apparently) go through the check_conflict routine.  I spent
> a few hours today trying to see how these statements work and simply
> haven't figured out how either is parsed with respect to setting
> the attributes.

I have had the same experience; I decided to fix that - see below:

> Well, it is obviously not done for us, or I won't have added the
> code to resolve.c :-)  I'll look at it some more tomorrow.  Time for
> some sleep.

Sorry, I was not trying to be sarcastic - just overstating the obvious!

How it works: (decl.c), for example

03375 match
03376 gfc_match_optional (void)
03377 {
03378 
03379   gfc_clear_attr (&current_attr);
03380   gfc_add_optional (&current_attr, NULL);
03381 
03382   return attr_decl ();
03383 }

line 3380 does nothing, following the previous gfc_clear_attr, that could
not be done with: current_attr.optional = 1;

The checks that are made do nothing because this is the only attribute set.

All the action happens in attr_decl () - this parses the rest of the 
statement.  Adding the check here fixes all these attribute statements and
reduces a the number of spurious calls to check_used, check_conflict
and check_done.

With the checks performed at the end of attr_decl1, your testcase produces:

 In file ext_int.f90:3

  external :: nint
                 1
Error: EXTERNAL attribute conflicts with INTRINSIC attribute at (1)

The patch is attached and regtests OK on Cygwin_NT.  I presume that it fixes
other PRs of the same kind but have not had time to look.

Best regards

Paul

-------------- next part --------------
A non-text attachment was scrubbed...
Name: attr.diff
Type: application/octet-stream
Size: 2922 bytes
Desc: attr.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060117/874e3973/attachment.obj>


More information about the Gcc-patches mailing list