Commit 99c72130 by Steven G. Kargl

re PR fortran/58001 (Make it possible to silence "Extension: Tab character in format" warning)

2016-11-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/58001
	* io.c (next_char_not_space): Update handling of a 'tab' in a FORMAT.
 	(format_lex): Adjust invocations of next_char_not_space().
 
2016-11-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/58001
	* gfortran.dg/fmt_tab_1.f90: Adjust testcase.
	* gfortran.dg/fmt_tab_2.f90: Ditto.

From-SVN: r242530
parent 243255c0
2016-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58001
* io.c (next_char_not_space): Update handling of a 'tab' in a FORMAT.
(format_lex): Adjust invocations of next_char_not_space().
2016-11-16 Andre Vehreschild <vehre@gcc.gnu.org> 2016-11-16 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78356 PR fortran/78356
......
...@@ -200,23 +200,14 @@ unget_char (void) ...@@ -200,23 +200,14 @@ unget_char (void)
/* Eat up the spaces and return a character. */ /* Eat up the spaces and return a character. */
static char static char
next_char_not_space (bool *error) next_char_not_space ()
{ {
char c; char c;
do do
{ {
error_element = c = next_char (NONSTRING); error_element = c = next_char (NONSTRING);
if (c == '\t') if (c == '\t')
{ gfc_warning (OPT_Wtabs, "Nonconforming tab character in format at %C");
if (gfc_option.allow_std & GFC_STD_GNU)
gfc_warning (0, "Extension: Tab character in format at %C");
else
{
gfc_error ("Extension: Tab character in format at %C");
*error = true;
return c;
}
}
} }
while (gfc_is_whitespace (c)); while (gfc_is_whitespace (c));
return c; return c;
...@@ -234,7 +225,6 @@ format_lex (void) ...@@ -234,7 +225,6 @@ format_lex (void)
char c, delim; char c, delim;
int zflag; int zflag;
int negative_flag; int negative_flag;
bool error = false;
if (saved_token != FMT_NONE) if (saved_token != FMT_NONE)
{ {
...@@ -243,7 +233,7 @@ format_lex (void) ...@@ -243,7 +233,7 @@ format_lex (void)
return token; return token;
} }
c = next_char_not_space (&error); c = next_char_not_space ();
negative_flag = 0; negative_flag = 0;
switch (c) switch (c)
...@@ -253,7 +243,7 @@ format_lex (void) ...@@ -253,7 +243,7 @@ format_lex (void)
/* Falls through. */ /* Falls through. */
case '+': case '+':
c = next_char_not_space (&error); c = next_char_not_space ();
if (!ISDIGIT (c)) if (!ISDIGIT (c))
{ {
token = FMT_UNKNOWN; token = FMT_UNKNOWN;
...@@ -264,7 +254,7 @@ format_lex (void) ...@@ -264,7 +254,7 @@ format_lex (void)
do do
{ {
c = next_char_not_space (&error); c = next_char_not_space ();
if (ISDIGIT (c)) if (ISDIGIT (c))
value = 10 * value + c - '0'; value = 10 * value + c - '0';
} }
...@@ -294,7 +284,7 @@ format_lex (void) ...@@ -294,7 +284,7 @@ format_lex (void)
do do
{ {
c = next_char_not_space (&error); c = next_char_not_space ();
if (ISDIGIT (c)) if (ISDIGIT (c))
{ {
value = 10 * value + c - '0'; value = 10 * value + c - '0';
...@@ -329,7 +319,7 @@ format_lex (void) ...@@ -329,7 +319,7 @@ format_lex (void)
break; break;
case 'T': case 'T':
c = next_char_not_space (&error); c = next_char_not_space ();
switch (c) switch (c)
{ {
case 'L': case 'L':
...@@ -357,7 +347,7 @@ format_lex (void) ...@@ -357,7 +347,7 @@ format_lex (void)
break; break;
case 'S': case 'S':
c = next_char_not_space (&error); c = next_char_not_space ();
if (c != 'P' && c != 'S') if (c != 'P' && c != 'S')
unget_char (); unget_char ();
...@@ -365,7 +355,7 @@ format_lex (void) ...@@ -365,7 +355,7 @@ format_lex (void)
break; break;
case 'B': case 'B':
c = next_char_not_space (&error); c = next_char_not_space ();
if (c == 'N' || c == 'Z') if (c == 'N' || c == 'Z')
token = FMT_BLANK; token = FMT_BLANK;
else else
...@@ -427,7 +417,7 @@ format_lex (void) ...@@ -427,7 +417,7 @@ format_lex (void)
break; break;
case 'E': case 'E':
c = next_char_not_space (&error); c = next_char_not_space ();
if (c == 'N' ) if (c == 'N' )
token = FMT_EN; token = FMT_EN;
else if (c == 'S') else if (c == 'S')
...@@ -457,7 +447,7 @@ format_lex (void) ...@@ -457,7 +447,7 @@ format_lex (void)
break; break;
case 'D': case 'D':
c = next_char_not_space (&error); c = next_char_not_space ();
if (c == 'P') if (c == 'P')
{ {
if (!gfc_notify_std (GFC_STD_F2003, "DP format " if (!gfc_notify_std (GFC_STD_F2003, "DP format "
...@@ -478,7 +468,7 @@ format_lex (void) ...@@ -478,7 +468,7 @@ format_lex (void)
"specifier not allowed at %C")) "specifier not allowed at %C"))
return FMT_ERROR; return FMT_ERROR;
token = FMT_DT; token = FMT_DT;
c = next_char_not_space (&error); c = next_char_not_space ();
if (c == '\'' || c == '"') if (c == '\'' || c == '"')
{ {
delim = c; delim = c;
...@@ -518,7 +508,7 @@ format_lex (void) ...@@ -518,7 +508,7 @@ format_lex (void)
break; break;
case 'R': case 'R':
c = next_char_not_space (&error); c = next_char_not_space ();
switch (c) switch (c)
{ {
case 'C': case 'C':
...@@ -559,9 +549,6 @@ format_lex (void) ...@@ -559,9 +549,6 @@ format_lex (void)
break; break;
} }
if (error)
return FMT_ERROR;
return token; return token;
} }
......
2016-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58001
* gfortran.dg/fmt_tab_1.f90: Adjust testcase.
* gfortran.dg/fmt_tab_2.f90: Ditto.
2016-11-16 Jakub Jelinek <jakub@redhat.com> 2016-11-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/78378 PR rtl-optimization/78378
......
! { dg-do compile } ! { dg-do compile }
! { dg-options -Wno-error=tabs } ! { dg-options -Wtabs }
! PR fortran/32987 ! PR fortran/32987
! PR fortran/58001
program TestFormat program TestFormat
write (*, 10) 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!') ! { dg-warning "tab character in format" }
end end
! { dg-excess-errors "tab character in format" }
! { dg-do compile } ! { dg-do compile }
! { dg-options "-std=f2003" } ! { dg-options "-std=f2003" }
! PR fortran/32987 ! PR fortran/32987
! PR fortran/58001
program TestFormat program TestFormat
write (*, 10) ! { dg-error "FORMAT label 10 at .1. not defined" } write (*, 10)
10 format ('Hello ', 'bug!') ! { dg-error "Extension: Tab character in format|Nonconforming tab character" } 10 format ('Hello ', 'bug!') ! { dg-warning "tab character in format" }
end end
! { dg-excess-errors "tab character in FORMAT" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment