public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Use gfc_symbol_state.
@ 2010-08-02 18:14 Mikael Morin
  2010-08-04  8:50 ` Daniel Kraft
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Morin @ 2010-08-02 18:14 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

Hello,

this implements an idea from Janus, to use gfc_symbol_state instead of 
gcc_assert (changed_syms == NULL).

While at it, the patch also modifies gfc_symbol_state as follows :
  - It changes the conditional internal error into a gcc_assert, as the 
error message was not very helpful to a non-gfortran-developer.
  - the gcc_assert also handles the #if GFC_DEBUG condition better, as 
it is enabled/disabled by configure (--enable-checking), documented, 
etc. So the #if GFC_DEBUG conditions are removed . Probably nobody was 
enabling it.
  - the function is renamed into something more descriptive 
(gfc_symbol_state->gfc_enforce_clean_symbol_state)

Regression tested on x86_64-unknown-freebsd8.0. OK for trunk ?

Mikael

[-- Attachment #2: symbol_state.log --]
[-- Type: text/plain, Size: 640 bytes --]

2010-08-02  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/42051
	PR fortran/44064
	* symbol.c (changed_syms): Made static again.
	(gfc_symbol_state): Don't conditionalize on GFC_DEBUG. 
	Changed conditional internal error into assert.
	Rename function to ...
	(gfc_enforce_clean_symbol_state): ... this.
	* gfortran.h (gfc_symbol_state, gfc_enforce_clean_symbol_state): 
	Rename the former to the latter.
	* parse.c (decode_statement, decode_omp_directive,
	decode_gcc_attribute): Update callers accordingly. Don't conditionalize
	on GFC_DEBUG.
	(changed_syms): Remove declaration.
	(next_statement): Use gfc_enforce_clean_symbol_state.


[-- Attachment #3: symbol_state.diff --]
[-- Type: text/plain, Size: 2652 bytes --]

Index: symbol.c
===================================================================
--- symbol.c	(revision 162821)
+++ symbol.c	(working copy)
@@ -98,7 +98,7 @@ gfc_namespace *gfc_global_ns_list;
 
 gfc_gsymbol *gfc_gsym_root = NULL;
 
-gfc_symbol *changed_syms = NULL;
+static gfc_symbol *changed_syms = NULL;
 
 gfc_dt_list *gfc_derived_types;
 
@@ -3442,16 +3442,13 @@ gfc_save_all (gfc_namespace *ns)
 }
 
 
-#ifdef GFC_DEBUG
 /* Make sure that no changes to symbols are pending.  */
 
 void
-gfc_symbol_state(void) {
-
-  if (changed_syms != NULL)
-    gfc_internal_error("Symbol changes still pending!");
+gfc_enforce_clean_symbol_state(void)
+{
+  gcc_assert (changed_syms == NULL);
 }
-#endif
 
 
 /************** Global symbol handling ************/
Index: gfortran.h
===================================================================
--- gfortran.h	(revision 162820)
+++ gfortran.h	(working copy)
@@ -2557,7 +2557,7 @@ void gfc_traverse_ns (gfc_namespace *, void (*)(gf
 void gfc_traverse_user_op (gfc_namespace *, void (*)(gfc_user_op *));
 void gfc_save_all (gfc_namespace *);
 
-void gfc_symbol_state (void);
+void gfc_enforce_clean_symbol_state (void);
 void gfc_free_dt_list (void);
 
 
Index: parse.c
===================================================================
--- parse.c	(revision 162821)
+++ parse.c	(working copy)
@@ -236,9 +236,7 @@ decode_statement (void)
   match m;
   char c;
 
-#ifdef GFC_DEBUG
-  gfc_symbol_state ();
-#endif
+  gfc_enforce_clean_symbol_state ();
 
   gfc_clear_error ();	/* Clear any pending errors.  */
   gfc_clear_warning ();	/* Clear any pending warnings.  */
@@ -484,9 +482,7 @@ decode_omp_directive (void)
   locus old_locus;
   char c;
 
-#ifdef GFC_DEBUG
-  gfc_symbol_state ();
-#endif
+  gfc_enforce_clean_symbol_state ();
 
   gfc_clear_error ();	/* Clear any pending errors.  */
   gfc_clear_warning ();	/* Clear any pending warnings.  */
@@ -588,9 +584,7 @@ decode_gcc_attribute (void)
 {
   locus old_locus;
 
-#ifdef GFC_DEBUG
-  gfc_symbol_state ();
-#endif
+  gfc_enforce_clean_symbol_state ();
 
   gfc_clear_error ();	/* Clear any pending errors.  */
   gfc_clear_warning ();	/* Clear any pending warnings.  */
@@ -879,7 +873,6 @@ blank_line:
   return ST_NONE;
 }
 
-extern gfc_symbol *changed_syms;
 
 /* Return the next non-ST_NONE statement to the caller.  We also worry
    about including files and the ends of include files at this stage.  */
@@ -890,8 +883,7 @@ next_statement (void)
   gfc_statement st;
   locus old_locus;
 
-  /* We start with a clean state.  */
-  gcc_assert (changed_syms == NULL);
+  gfc_enforce_clean_symbol_state ();
 
   gfc_new_block = NULL;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, fortran] Use gfc_symbol_state.
  2010-08-02 18:14 [patch, fortran] Use gfc_symbol_state Mikael Morin
@ 2010-08-04  8:50 ` Daniel Kraft
  2010-08-04 14:19   ` Mikael Morin
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Kraft @ 2010-08-04  8:50 UTC (permalink / raw)
  To: Mikael Morin; +Cc: fortran, gcc-patches

Mikael Morin wrote:
> Hello,
> 
> this implements an idea from Janus, to use gfc_symbol_state instead of 
> gcc_assert (changed_syms == NULL).
> 
> While at it, the patch also modifies gfc_symbol_state as follows :
>  - It changes the conditional internal error into a gcc_assert, as the 
> error message was not very helpful to a non-gfortran-developer.
>  - the gcc_assert also handles the #if GFC_DEBUG condition better, as it 
> is enabled/disabled by configure (--enable-checking), documented, etc. 
> So the #if GFC_DEBUG conditions are removed . Probably nobody was 
> enabling it.
>  - the function is renamed into something more descriptive 
> (gfc_symbol_state->gfc_enforce_clean_symbol_state)
> 
> Regression tested on x86_64-unknown-freebsd8.0. OK for trunk ?

Ok.  Thanks for the patch!

Daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, fortran] Use gfc_symbol_state.
  2010-08-04  8:50 ` Daniel Kraft
@ 2010-08-04 14:19   ` Mikael Morin
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Morin @ 2010-08-04 14:19 UTC (permalink / raw)
  To: Daniel Kraft; +Cc: fortran, gcc-patches

Le 04.08.2010 10:55, Daniel Kraft a écrit :
>
> Mikael Morin wrote:
>> Hello,
>>
>> this implements an idea from Janus, to use gfc_symbol_state instead of
>> gcc_assert (changed_syms == NULL).
>>
>> While at it, the patch also modifies gfc_symbol_state as follows :
>> - It changes the conditional internal error into a gcc_assert, as the
>> error message was not very helpful to a non-gfortran-developer.
>> - the gcc_assert also handles the #if GFC_DEBUG condition better, as
>> it is enabled/disabled by configure (--enable-checking), documented,
>> etc. So the #if GFC_DEBUG conditions are removed . Probably nobody was
>> enabling it.
>> - the function is renamed into something more descriptive
>> (gfc_symbol_state->gfc_enforce_clean_symbol_state)
>>
>> Regression tested on x86_64-unknown-freebsd8.0. OK for trunk ?
>
> Ok. Thanks for the patch!
>
> Daniel
>
Committed at revision 162865. Thanks

Mikael

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-04 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-02 18:14 [patch, fortran] Use gfc_symbol_state Mikael Morin
2010-08-04  8:50 ` Daniel Kraft
2010-08-04 14:19   ` Mikael Morin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).