[Patch,gfortran] ENUMERATIONS and ENUMERATORS

Tobias.Schlueter@Physik.Uni-Muenchen.DE Tobias.Schlueter@Physik.Uni-Muenchen.DE
Fri Oct 21 15:22:00 GMT 2005


Quoting Gaurav Gautam <gauravgautam123@gmail.com>:
> > This won't work, you're accepting e.g. a REAL declaration. I really think
> > it
> > would be simpler if you wrote a matcher for the interior of an ENUM block,
> > as
> > there are only two allowed statements: ENUMERATOR and END ENUM. You could
> > then do away with an umber of special cases in what follows.
> >
>
> This is working. I think you did not get this section of code. let me
> explain this to you
> This section of code is in "match_type_spec". this function returns the
> match status. I am cheking the "ts->type " to be a BT_INTEGER just when the
> function returns.(back to match_data_decl()).
>
> there is a check. you can look at the section of code below.
>
> m = match_type_spec (&current_ts, 0);)
> if (m != MATCH_YES)
> return m;
>
> + if ((gfc_current_state () == COMP_ENUM) && (current_ts.type !=
> BT_INTEGER))
> + {
> + gfc_error ("Syntax error in ENUMERATOR definition at %C");
> + gfc_free_enum_history ();
> + return MATCH_ERROR;
> + }

Indeed, I missed that.  Why not just return early, if there's no ENUMERATOR
statement, I you will then get the default syntax error message, unless there's
another something that I'm missing.

- Tobi



More information about the Gcc-patches mailing list