[patch] support for -fdump-ada-spec

Arnaud Charlet charlet@adacore.com
Thu May 6 15:09:00 GMT 2010


> What I mean is convert the preprocessing token to a tree value the same
> way the C front end does, then convert the tree to an appropriate Ada
> representation.

Could you give some pointers to do that? Initially I said this sounded
like lots of extra work, but if it's simple to do, why not. I'm in particular
concerned that I'll need to add an expression converter (from C expressions
to Ada expression), which is currently intentionally avoided, we only
convert tree declarations, and no expressions.

If it's complex, I'd like to defer it to a second stage, since this is
more in the 'nice to have category'.

> That way you don't need to duplicate any logic for interpreting escape
> sequences in strings, for example, since you let the existing code produce
> the sequence of bytes that would represent the string on the target.  Nor
> do you need to know about the various different forms of integer and real
> constants unless you feel it's important for the Ada code to use the same
> base for them as the C code does.

Actually keeping the information on the 'base' is certainly important and
useful, so that's one area where we do want to keep the original info/token.

As for strings, we will need to perform so extra processing no matter what
representation is used (e.g. all non printable chars will need to be
either declared unsupported or handled as done in my patch for \n, \t, \r),
so I'm not convinced of the added value.

Again, the idea as far as preprocessor handling is to convert the most common
cases which are also the simple cases: simple ASCII strings and simple
integer literals. I am not convinced that converting to a tree value would
add much value for these cases, even though in the medium term, doing such
convertion may prove useful for more complex cases.

Arno



More information about the Gcc-patches mailing list