The following program gives a bogus warning when compiled with -Wall or -std=f95 or -std=f2003: program gfcbug59 print *, "Hello"& // " World" ! Bogus warning with -Wall or -std=f95 or -std=f2003 end program gfcbug59 % gfc -Wall gfcbug59.f90 gfcbug59.f90:3.8: // " World" ! Bogus warning with -Wall or -std=f95 or -std=f2003 1 Warning: Missing '&' in continued character constant at (1) gfcbug59.f90:3.8: // " World" ! Bogus warning with -Wall or -std=f95 or -std=f2003 1 Warning: Missing '&' in continued character constant at (1)
Confirmed. One needs the second "&" for: "Hello& & World" But one does not need it for: "Hello" & , "World" The following seems to be a gfortran/ifort extension: "Hello& World" For this case, the warning / std error is correct. The bug in gfortran is that "Hello" & is correctly seen as non-character context whereas "Hello" & is wrongly regarded as character context.
> The bug in gfortran is that "Hello" & is correctly seen as non-character > context whereas "Hello" & is wrongly regarded as character context. The last line should be: "Hello"& without space between " and &. Note: Printing an error twice is also a bug.
Patch. Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (Revision 122328) +++ gcc/fortran/primary.c (Arbeitskopie) @@ -773,7 +773,7 @@ return c; old_locus = gfc_current_locus; - c = gfc_next_char_literal (1); + c = gfc_next_char_literal (0); if (c == delimiter) return c; @@ -852,7 +852,7 @@ match_string_constant (gfc_expr **result) { char *p, name[GFC_MAX_SYMBOL_LEN + 1]; - int i, c, kind, length, delimiter; + int i, c, kind, length, delimiter, warn_ampersand; locus old_locus, start_locus; gfc_symbol *sym; gfc_expr *e; @@ -979,10 +979,16 @@ gfc_current_locus = start_locus; gfc_next_char (); /* Skip delimiter */ + /* We disable the warning for the following loop as the warning has already + been printed in the loop above. */ + warn_ampersand = gfc_option.warn_ampersand; + gfc_option.warn_ampersand = 0; + for (i = 0; i < length; i++) *p++ = next_string_char (delimiter); *p = '\0'; /* TODO: C-style string is for development/debug purposes. */ + gfc_option.warn_ampersand = warn_ampersand; if (next_string_char (delimiter) != -1) gfc_internal_error ("match_string_constant(): Delimiter not found"); + if (next_string_char (delimiter) != -1) gfc_internal_error ("match_string_constant(): Delimiter not found");
Subject: Bug 30968 Author: burnus Date: Wed Feb 28 08:03:47 2007 New Revision: 122401 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122401 Log: 2007-02-28 Tobias Burnus <burnus@net-b.de> PR fortran/30968 * primary.c (next_string_char): Correct reading a character after the delimiter. (match_string_constant): Print warning message only once. 2007-02-28 Tobias Burnus <burnus@net-b.de> PR fortran/30968 * gfortran.dg/continuation_7.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/continuation_7.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/primary.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 30968 Author: burnus Date: Mon Mar 5 12:58:14 2007 New Revision: 122547 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122547 Log: 2007-03-05 Tobias Burnus <burnus@net-b.de> PR fortran/30968 * primary.c (next_string_char): Correct reading a character after the delimiter. (match_string_constant): Print warning message only once. 2007-03-05 Tobias Burnus <burnus@net-b.de> PR fortran/30968 * gfortran.dg/continuation_7.f90: New test. Added: branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/continuation_7.f90 Modified: branches/gcc-4_2-branch/gcc/fortran/ChangeLog branches/gcc-4_2-branch/gcc/fortran/primary.c branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
Fixed in 4.2 (and 4.3). I don't think it is worth to porting to 4.1. -> close bug.