[fortran] Add runtime warning mechanism to libgfortran

Paul Thomas paulthomas2@wanadoo.fr
Wed Aug 10 15:35:00 GMT 2005


:REVIEWID <141>:

I have reviewed this patch, it works, and I regtested it on FC3/Athlon.

I tried and partially succeded to write a testcase for it, based on FX's example (see 5 below).

It's OK for mainline and 4.0, with a couple of remarks.

Cheers

Paul T 

1) The comment in gfortran.h need not be apologetic; hopefully we are going to use this feature.  I would write:

+  /* Set if the is the symbol for the main program.  This is the least
+     cumbersome way to communicate this function property without
+     strcmp'ing with __MAIN everywhere.  */
+  unsigned is_main_program:1;

2) This is not specific to your patch but a call to arms:

This

+/* Flags to specify which standard/extension contains a feature.
+   Keep them in sync with their counterparts in gcc/fortran/gfortran.h.  */
+#define GFC_STD_LEGACY          (1<<6) /* Backward compatibility.  */
+#define GFC_STD_GNU             (1<<5)    /* GNU Fortran extension.  */
+#define GFC_STD_F2003           (1<<4)    /* New in F2003.  */
+/* Note that no features were obsoleted nor deleted in F2003.  */
+#define GFC_STD_F95             (1<<3)    /* New in F95.  */
+#define GFC_STD_F95_DEL         (1<<2)    /* Deleted in F95.  */
+#define GFC_STD_F95_OBS         (1<<1)    /* Obsoleted in F95.  */
+#define GFC_STD_F77             (1<<0)    /* Up to and including F77.  */

is an example of an increasing number of enumerations and defines that span fortran and libgfortran.
These need synchronizing - at present, by hand.  Is it not time that they found a common repository?

3) Your notify_standard is of type void, rather than type try, as in the front end.
This later can be useful for modifying the response according to local conditions.

4) Why did you chose to introduce compile_options.c? 
To speed up testing, I put its rather tiny content at the top of main.c.

5) I could not persuade dejaGnu to detect the runtime error with any combination of directives.

This works by detecting the compile-time and run-time warnings.

! Test runtime warnings using non-standard $ editing - PR20006.
!
! Contributor Francois-Xavier Coudert  <coudert@clipper.ens.fr>
!
! { dg-options "-pedantic" }
! { dg-do run }
!
      character*5 c
      open (42,status='scratch')
      write (42,'(A,$)') 'abc' ! { dg-warning ".*descriptor" "" }
      write (42,'(A)') 'de'
      rewind (42)
      read (42,'(A)') c
      close (42)
      if (c /= 'abcde') call abort ()
      end
! { dg-warning ".*descriptor" "" 10}









More information about the Fortran mailing list