http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #9 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- The following patch causes gfortran to treat a tab within a FORMAT statement that same as it does elsewhere for the appearance of a nonconforming use of tab. The two tet cases have been adjusted. Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 201382) +++ gcc/fortran/io.c (working copy) @@ -192,23 +192,14 @@ unget_char (void) /* Eat up the spaces and return a character. */ static char -next_char_not_space (bool *error) +next_char_not_space () { char c; do { error_element = c = next_char (NONSTRING); - if (c == '\t') - { - if (gfc_option.allow_std & GFC_STD_GNU) - gfc_warning ("Extension: Tab character in format at %C"); - else - { - gfc_error ("Extension: Tab character in format at %C"); - *error = true; - return c; - } - } + if (!gfc_option.warn_tabs && c == '\t') + gfc_warning ("Nonconforming tab character in FORMAT at %C"); } while (gfc_is_whitespace (c)); return c; @@ -226,7 +217,6 @@ format_lex (void) char c, delim; int zflag; int negative_flag; - bool error = false; if (saved_token != FMT_NONE) { @@ -235,7 +225,7 @@ format_lex (void) return token; } - c = next_char_not_space (&error); + c = next_char_not_space (); negative_flag = 0; switch (c) @@ -245,7 +235,7 @@ format_lex (void) /* Falls through. */ case '+': - c = next_char_not_space (&error); + c = next_char_not_space (); if (!ISDIGIT (c)) { token = FMT_UNKNOWN; @@ -256,7 +246,7 @@ format_lex (void) do { - c = next_char_not_space (&error); + c = next_char_not_space (); if (ISDIGIT (c)) value = 10 * value + c - '0'; } @@ -286,7 +276,7 @@ format_lex (void) do { - c = next_char_not_space (&error); + c = next_char_not_space (); if (ISDIGIT (c)) { value = 10 * value + c - '0'; @@ -321,7 +311,7 @@ format_lex (void) break; case 'T': - c = next_char_not_space (&error); + c = next_char_not_space (); switch (c) { case 'L': @@ -349,7 +339,7 @@ format_lex (void) break; case 'S': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c != 'P' && c != 'S') unget_char (); @@ -357,7 +347,7 @@ format_lex (void) break; case 'B': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == 'N' || c == 'Z') token = FMT_BLANK; else @@ -419,7 +409,7 @@ format_lex (void) break; case 'E': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == 'N' ) token = FMT_EN; else if (c == 'S') @@ -449,7 +439,7 @@ format_lex (void) break; case 'D': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == 'P') { if (!gfc_notify_std (GFC_STD_F2003, "DP format " @@ -472,7 +462,7 @@ format_lex (void) break; case 'R': - c = next_char_not_space (&error); + c = next_char_not_space (); switch (c) { case 'C': @@ -513,9 +503,6 @@ format_lex (void) break; } - if (error) - return FMT_ERROR; - return token; } Index: gcc/testsuite/gfortran.dg/fmt_tab_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/fmt_tab_1.f90 (revision 201382) +++ gcc/testsuite/gfortran.dg/fmt_tab_1.f90 (working copy) @@ -1,6 +1,9 @@ -! { dg-do run } +! { dg-do compile } +! { dg-options "-Wtabs" } ! PR fortran/32987 program TestFormat write (*, 10) - 10 format ('Hello ', 'bug!') ! { dg-warning "Extension: Tab character in format" } + ! There is a tab character before 'bug'. This is accepted without + ! the -Wno-tabs option or a -std= option. + 10 format ('Hello ', 'bug!') end Index: gcc/testsuite/gfortran.dg/fmt_tab_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/fmt_tab_2.f90 (revision 201382) +++ gcc/testsuite/gfortran.dg/fmt_tab_2.f90 (working copy) @@ -2,6 +2,6 @@ ! { dg-options "-std=f2003" } ! PR fortran/32987 program TestFormat - write (*, 10) ! { dg-error "FORMAT label 10 at .1. not defined" } - 10 format ('Hello ', 'bug!') ! { dg-error "Extension: Tab character in format" } + write (*, 10) + 10 format ('Hello ', 'bug!') ! { dg-warning "tab character in FORMAT" } end