This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/46705] Spurious "Missing '&' in continued character constant" warning occurs twice


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.


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