PROTECTED attribute - almost working patch

Tobias Burnus burnus@net-b.de
Sun Dec 10 05:43:00 GMT 2006


Hello,

attached you can find my current patch. I think it is finished except
for a test of   common/external/intrinsic conflicts with protected. And
a test for equivalence (all or none of the objects need to be
protected). And except of the following:

I have a strange problem:

(a) Using the "protected :: " statement, everything works as expected.
(b) Using the ", protected" attribute everything behaves very oddly:

Looking at -fdump-parse-tree one finds no PROTECTED and using
use-associated protected variables is possible.
(I copied the implementation of VOLATILE, which works in
-fdump-parse-tree; -fdump-parse-tree works also with the protected
statement, which also uses "gfc_add_protected".)

I definitely call "gfc_add_protected" as one can also see by using 
"real, parameter, protected :: a" or "real, protected, parameter :: a",
which both gives the expected error (protected and parameter have a
conflict).

But "real, protected :: a; external a" does not give an error, while
"real :: a; external a; protected :: a" does.

The attribute "protected" seems to be reset right after reading one line
of source - and this resetting does not happen for other attributes nor
when using the protected statement.

Any idea? - I'm completely puzzled and have not the slightest idea why
this happens.

Tobias

Instead of a changelog (for which I wait for the final patch), an
excerpt of the Fortran 2003 standard:

---------------------------

5.1.2.12 PROTECTED attribute

The PROTECTED attribute imposes limitations on the usage of module
entities. Other than within the module in which an entity is given the
PROTECTED attribute, (1) if it is a nonpointer object, it is not
definable, and (2) if it is a pointer, its association status shall not
be changed except that it may become undefined if its target is
deallocated other than through the pointer (16.4.2.1.3) or if its target
becomes undefined by execution of a RETURN or END statement. If an
object has the PROTECTED attribute, all of its subobjects have the
PROTECTED attribute.

5.2.11 PROTECTED statement

R542 protected-stmt is PROTECTED [ :: ] entity-name-list
The PROTECTED statement specifies the PROTECTED attribute (5.1.2.12) for
a list of entities.



C534 (R503) The PROTECTED attribute is permitted only in the
specification part of a module.

C535 (R501) The PROTECTED attribute is permitted only for a procedure
pointer or named variable that is not in a common block.

C536 (R501) If the PROTECTED attribute is specified, the EXTERNAL,
INTRINSIC, or PARAMETER attribute shall not be specified.

C537 A nonpointer object that has the PROTECTED attribute and is
accessed by use association shall not appear in a variable definition
context (16.5.7) or as the data-target or proc-target in a
pointer-assignment-stmt.

C538 A pointer object that has the PROTECTED attribute and is accessed
by use association shall not appear as
 (1) A pointer-object in a nullify-stmt,
 (2) A data-pointer-object or proc-pointer-object in a
pointer-assignment-stmt,
 (3) An allocate-object in an allocate-stmt or deallocate-stmt, or
 (4) An actual argument in a reference to a procedure if the associated
dummy argument is a pointer with the INTENT(OUT) or INTENT(INOUT) attribute.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: protected.diff
Type: text/x-patch
Size: 21479 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20061210/d1070564/attachment.bin>


More information about the Fortran mailing list