------- Comment #7 from janus at gcc dot gnu dot org  2010-03-04 09:17 -------
(In reply to comment #6)
> Without looking at the code yet, the matcher must see a space or double colon
> after the word FINAL before matching it.  If it sees anything else, its a
> MATCH_NO not a MATCH_ERROR.  If this is being done then the syntax error in 
> the
> array qualifiers may/should kick in.

Yes, that's exactly what my patch in comment #5 does.


> Syntax for FINAL is :
> 
> FINAL [ :: ] final-subroutine-name-list
> 
> So I think your patch is OK for MATCH_NO but a MATCH_YES must see :: as well.

No, to get a MATCH_YES we don't have to see :: since it's optional. Anyway,
matching the rest of the statement is handled correctly further down in
gfc_match_final_decl. The purpose of this patch is simply to reject the FINAL
statement with a MATCH_NO before we throw an error.


> Free or Fixed form is irrelevant.  Fixed form may allow things like F I N  AL
> but it still must have :: (or : whitespace :) to match.

Ok, then the patch may look like this:


Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c  (revision 157215)
+++ gcc/fortran/decl.c  (working copy)
@@ -7803,13 +7803,17 @@ error:
 match
 gfc_match_final_decl (void)
 {
-  char name[GFC_MAX_SYMBOL_LEN + 1];
+  char name[GFC_MAX_SYMBOL_LEN + 1],c;
   gfc_symbol* sym;
   match m;
   gfc_namespace* module_ns;
   bool first, last;
   gfc_symbol* block;

+  c = gfc_peek_ascii_char ();
+  if (!gfc_is_whitespace (c) && c != ':')
+    return MATCH_NO;
+  
   if (gfc_state_stack->state != COMP_DERIVED_CONTAINS)
     {
       gfc_error ("FINAL declaration at %C must be inside a derived type "


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43244

Reply via email to