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

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2010-12-11 
15:54:38 UTC ---
If you look at the test case you will see that the '&' issue is outside of the
quotes in the format statement.  Right away this told me we should not be
getting the warning at all since it is inside the "in_string" condition in
scanner.c: gfc_next_char_literal.

I found the problem here:

Index: io.c
===================================================================
--- io.c    (revision 167624)
+++ io.c    (working copy)
@@ -383,7 +383,7 @@ format_lex (void)

       if (c == delim)
         {
-          c = next_char (1);
+          c = next_char (0);

           if (c == '\0')
         {

Just above this code in io.c, we have just detected the closing quote so we
should not call next_char with the in_string flag.  I have regression tested
this and all our existing -Wampersand tests still work fine with this change. 
Then we correctly get no warning with the first test case.

Now, if we do this:

1 FORMAT (' &
'  )
END

We get a double warning. I think this is because in the scanner we may scan a
line more than once looking for matches.  I am not decided yet what to do with
this bit.

Reply via email to