[Patch,gfortran] ENUMERATIONS and ENUMERATORS

Gaurav Gautam, Noida gauravga@noida.hcltech.com
Wed Aug 3 07:15:00 GMT 2005


Hi,

Thanks for your review and comments.

I am working on the problem and will resend the patch after fixing it.

Regards
Gaurav Gautam

> -----Original Message-----
> From: Paul Brook [mailto:paul@codesourcery.com]
> Sent: Monday, August 01, 2005 8:08 PM
> To: fortran@gcc.gnu.org
> Cc: Gaurav Gautam, Noida; Francois-Xavier Coudert
> Subject: Re: [Patch,gfortran] ENUMERATIONS and ENUMERATORS
> 
> > 2) Storing the parse tree and modifications in symbol table
> >
> > According to the fortran standard:
> >
> > "The following declaration might be equivalent to the above enumeration
> > definition. INTEGER(SELECTED_INT_KIND(2)), PARAMETER :: RED = 4, BLUE =
> 9,
> > YELLOW = 10 "
> >
> > The enumerators that have been parsed have actually been stored as
> integers
> > with parameter attribute
> >
> > and with the kind type given by (SELECTED_INT_KIND())
> >
> > Thus the enumeration shown in the example after parsing, will appear to
> the
> > rest of frontend as the following statement has been parsed:
> >
> > INTEGER(SELECTED_INT_KIND(arg)), PARAMETER :: RED = 4, BLUE = 9, YELLOW
> =
> > 10 "
> >
> > where the argument "arg" of SELECTED_INT_KIND() is decided by the
> following
> > equation.
> >
> >  -10 ^ arg         < maximum of the values of all enumerators <    10^
> arg
> >    -----equation
> >
> > the maximum values of enumerator here is 10 so
> > arg by above equation comes out to be 2.
> 
> This is wrong. Section 4.6 "Enumerations and enumarators" says:
> 
> "For an enumeration the kind is selected such that an integer type with
> that
> kind is interoperable with the corresponding C enumeration type."
> 
> ie. you should use the same rules as the C frontend. See also the effect
> of
> -fshort-enums.
> 
> Paul



More information about the Fortran mailing list