This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Adding UNION/MAP -- Feedback and tips pls!


Russell Brennan wrote:
I was wondering if there is a flow diagram or something that outlines
the steps the frontend takes during compilation, as I haven't been
able to find anything and the functions are hit or miss as far as
in-code documentation goes?

I think there is no real flow diagram – and it also depends a bit which kind of code you add. However, you seem to have found the important bits in the parser.


I haven't been able to get a grasp on which global variables are key,
is there any documentation outlining what the variables are for and
how they are used?

Hmm, there shouldn't be many global variables, the main ones are gfc_current_locus and gfc_current_ns.

I am using -fdump-parse-tree right now which seems very helpful; are
there other flags that you guys have found particularly illuminating?

Well, you can also use the debugger. But don't use: gdb --args gfortran file.f90

That only debugs the compiler wrapper; use
gdb --args `gfortran -v file.f90 2>&1 |grep f951`

to debug the real compiler. With "gfc_debug_expr(expr)" you can print the FE expression ("p gfc_debug_expr(expr)" in the debugger); a "tree" you can print with "p debug_tree(decl)".

+  // TODO: This doesn't hit if there is junk after the union statement.  FIND
+  // A COMPARABLE STATEMENT TO USE AS A TEMPLATE!
+  if ( gfc_current_block () == NULL) {
+      gfc_error ("Unexpected junk after UNION statement at %C");

It could also just be that it just doesn't print, depending what junk you had. Recall that in Fortran (fixed form) spaces have no meaning. Hence:


do r = sinf(x)+cos(y),10.0
and
do r = sinf(x)+cos(y)

have to be handled correctly. In the first case, one has a DO loop with "r" as loop variable, in the second line, one has an assignment to the variable "dor". Thus, the compiler tries to parse a line with one meaning, if it fails, it tries it differently, etc - until there are no more options. Thus "gfc_error" printing is delayed.

During development, you could try "gfc_error_now" to ensure that the error is printed.


Tobias



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]