This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] Fix NULL reference types.
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: paul at nowt dot org, gcc at gcc dot gnu dot org
- Date: Wed, 18 Aug 2004 14:43:29 +0100
- Subject: Re: [gfortran] Fix NULL reference types.
- Organization: CodeSourcery LLC
- References: <10408181318.AA18093@vlsi1.ultra.nyu.edu>
Richard Kenner wrote:
Apparently the optimizers [could] assume that a reference type
argument is never NULL.
Is this really correct? If so, this has the potential of simplifying lots of
code in Ada if we use REFERENCE_TYPE for things that can never be null.
I believe so, it is certainly true for C++. I attach a documentation patch,
explaining such, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-08-18 Nathan Sidwell <nathan@codesourcery.com>
* tree.def (REFERENCE_TYPE): Clarify meaning.
* doc/c-tree.texi (REFERENCE_TYPE): Likewise.
Index: tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.def,v
retrieving revision 1.97
diff -c -3 -p -r1.97 tree.def
*** tree.def 6 Aug 2004 10:40:30 -0000 1.97
--- tree.def 18 Aug 2004 13:42:50 -0000
*************** DEFTREECODE (POINTER_TYPE, "pointer_type
*** 186,193 ****
that the offset is relative to. */
DEFTREECODE (OFFSET_TYPE, "offset_type", 't', 0)
! /* A reference is like a pointer except that it is coerced
! automatically to the value it points to. Used in C++. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", 't', 0)
/* METHOD_TYPE is the type of a function which takes an extra first
--- 186,194 ----
that the offset is relative to. */
DEFTREECODE (OFFSET_TYPE, "offset_type", 't', 0)
! /* A reference is like a pointer except that it can never have a NULL
! value. Also front ends, such as C++, could automatically
! dereference it to the referred-to object. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", 't', 0)
/* METHOD_TYPE is the type of a function which takes an extra first
Index: doc/c-tree.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/c-tree.texi,v
retrieving revision 1.61
diff -c -3 -p -r1.61 c-tree.texi
*** doc/c-tree.texi 20 Jul 2004 12:26:02 -0000 1.61
--- doc/c-tree.texi 18 Aug 2004 13:42:52 -0000
*************** For a pointer to data member type of the
*** 484,490 ****
@item REFERENCE_TYPE
Used to represent reference types. The @code{TREE_TYPE} gives the type
! to which this type refers.
@item FUNCTION_TYPE
Used to represent the type of non-member functions and of static member
--- 484,493 ----
@item REFERENCE_TYPE
Used to represent reference types. The @code{TREE_TYPE} gives the type
! to which this type refers. A @code{REFERENCE_TYPE} is like a
! @code{POINTER_TYPE}, except that it can never have a NULL value.
! Frontends might automatically dereference an expression of
! @code{REFERENCE_TYPE} (g++ does this).
@item FUNCTION_TYPE
Used to represent the type of non-member functions and of static member