public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning
@ 2013-07-27 10:36 burnus at gcc dot gnu.org
2013-07-27 14:55 ` [Bug fortran/58001] " kargl at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-07-27 10:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
Bug ID: 58001
Summary: Make it possible to silence "Extension: Tab character
in format" warning
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
For indenting the source code, gfortran warns only with -std=f* or with -Wtab.
However, for format strings, it always warns - and with -std=f* it even turns
the warning into an error! (see io.c's next_char_not_space)
Example:
1894 format( '123')
end
(The tab is before '123'. A tab in the string itself is not warned for.)
Maybe the best would be to disable this warning with -std=legacy - and refer to
-std=legacy in the -std=gnu warning?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
@ 2013-07-27 14:55 ` kargl at gcc dot gnu.org
2013-07-30 12:59 ` dominiq at lps dot ens.fr
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu.org @ 2013-07-27 14:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Tobias Burnus from comment #0)
> For indenting the source code, gfortran warns only with -std=f* or with
> -Wtab.
Please, check the archive. At one time gfortran would issue a warning
if a tab was used in a nonconforming context. Too many people were
upset about this, so the -W[no-]tab option, which has a convoluted history,
was the compromise.
> However, for format strings, it always warns - and with -std=f* it even
> turns the warning into an error! (see io.c's next_char_not_space)
>
> Example:
>
> 1894 format( '123')
> end
>
> (The tab is before '123'. A tab in the string itself is not warned for.)
>
> Maybe the best would be to disable this warning with -std=legacy - and refer
> to -std=legacy in the -std=gnu warning?
Tab is not and never has been a member of the Fortran character set.
The above line of code is nonconforming. Gfortran, IMNSHO, should
always issue an error, but I lost that battle years ago.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
2013-07-27 14:55 ` [Bug fortran/58001] " kargl at gcc dot gnu.org
@ 2013-07-30 12:59 ` dominiq at lps dot ens.fr
2013-07-30 17:42 ` sgk at troutmask dot apl.washington.edu
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-07-30 12:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-07-30
Ever confirmed|0 |1
--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Compiling the following code with -Wtabs
print *, "A string with Tabs instead of spaces"
print 1894
1894 format( '123')
end
gives
pr58001.f90:3.14:
1894 format( '123')
1
Warning: Extension: Tab character in format at (1)
If compiled with -Wno-tabs, it gives
pr58001.f90:2.1:
print 1894
1
Warning: Nonconforming tab character at (1)
pr58001.f90:3.14:
1894 format( '123')
1
Warning: Nonconforming tab character at (1)
pr58001.f90:3.14:
1894 format( '123')
1
Warning: Extension: Tab character in format at (1)
Is this the expected behavior?-(I was expecting the later output for -Wtabs,
and no warning with -Wno-tabs: on most options Wno-* suppress the warnings for
the corresponding option.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
2013-07-27 14:55 ` [Bug fortran/58001] " kargl at gcc dot gnu.org
2013-07-30 12:59 ` dominiq at lps dot ens.fr
@ 2013-07-30 17:42 ` sgk at troutmask dot apl.washington.edu
2013-07-30 17:58 ` dominiq at lps dot ens.fr
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2013-07-30 17:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 30, 2013 at 12:59:00PM +0000, dominiq at lps dot ens.fr wrote:
>
> print *, "A string with Tabs instead of spaces"
> print 1894
> 1894 format( '123')
> end
>
According to both vi and nedit, there are no tabs in the
above code. I assume that this is cut-n-paste from an
xterm term.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2013-07-30 17:42 ` sgk at troutmask dot apl.washington.edu
@ 2013-07-30 17:58 ` dominiq at lps dot ens.fr
2013-07-30 17:59 ` dominiq at lps dot ens.fr
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-07-30 17:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> According to both vi and nedit, there are no tabs in the
> above code. I assume that this is cut-n-paste from an
> xterm term.
With Safari I see the tabs in comment #2, but not in what has been pasted in
comment #3. I am attaching the code.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2013-07-30 17:58 ` dominiq at lps dot ens.fr
@ 2013-07-30 17:59 ` dominiq at lps dot ens.fr
2013-07-30 18:02 ` sgk at troutmask dot apl.washington.edu
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-07-30 17:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Created attachment 30573
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30573&action=edit
test case with tabs
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2013-07-30 17:59 ` dominiq at lps dot ens.fr
@ 2013-07-30 18:02 ` sgk at troutmask dot apl.washington.edu
2013-07-30 18:16 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2013-07-30 18:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 30, 2013 at 12:59:00PM +0000, dominiq at lps dot ens.fr wrote:
>
> If compiled with -Wno-tabs, it gives
>
> pr58001.f90:2.1:
>
> print 1894
> 1
> Warning: Nonconforming tab character at (1)
> pr58001.f90:3.14:
>
> 1894 format( '123')
> 1
> Warning: Nonconforming tab character at (1)
> pr58001.f90:3.14:
>
> 1894 format( '123')
> 1
> Warning: Extension: Tab character in format at (1)
>
> Is this the expected behavior?
With -Wno-tabs, gfortran should report a warning for the
occurence of every tab used in the context of a character
from the Fortran character set. Taking your code, which I've
deleted here, and replace all whitespace by tabs, I get the
expected number of warnings. Historically, I wanted to use
-Wtabs as you expected, but there was too much wailing on
the gfortran lists, so it was changed to -Wno-tabs with the
meaning that "no tabs are allowed" in the context of the
Fortran character set. You'll notice that tabs within
a literal character string are not flagged. The history
of -Wtabs verse -Wno-tabs can be found in the mailinglist
archive.
Now, for the problem at hand, it seems that there is a
bug in io.c. Here the code in question:
/* Eat up the spaces and return a character. */
static char
next_char_not_space (bool *error)
{
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;
}
}
}
while (gfc_is_whitespace (c));
return c;
}
Notice that there is no check for gfc_option.warn_tabs.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2013-07-30 18:02 ` sgk at troutmask dot apl.washington.edu
@ 2013-07-30 18:16 ` dominiq at lps dot ens.fr
2013-07-30 19:07 ` sgk at troutmask dot apl.washington.edu
2013-07-31 19:37 ` sgk at troutmask dot apl.washington.edu
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-07-30 18:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> With -Wno-tabs, gfortran should report a warning for the
> occurence of every tab used in the context of a character
> from the Fortran character set. Taking your code, which I've
> deleted here, and replace all whitespace by tabs, I get the
> expected number of warnings. Historically, I wanted to use
> -Wtabs as you expected, but there was too much wailing on
> the gfortran lists, so it was changed to -Wno-tabs with the
> meaning that "no tabs are allowed" in the context of the
> Fortran character set. You'll notice that tabs within
> a literal character string are not flagged.
I cannot understand the rationale of this choice, but I guess it's too late to
change it!-(
> The history of -Wtabs verse -Wno-tabs can be found in the mailinglist
> archive.
No interest to dig the archives on this issue.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2013-07-30 18:16 ` dominiq at lps dot ens.fr
@ 2013-07-30 19:07 ` sgk at troutmask dot apl.washington.edu
2013-07-31 19:37 ` sgk at troutmask dot apl.washington.edu
8 siblings, 0 replies; 10+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2013-07-30 19:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
--- Comment #8 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 30, 2013 at 06:16:27PM +0000, dominiq at lps dot ens.fr wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58001
>
> --- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> > With -Wno-tabs, gfortran should report a warning for the
> > occurence of every tab used in the context of a character
> > from the Fortran character set. Taking your code, which I've
> > deleted here, and replace all whitespace by tabs, I get the
> > expected number of warnings. Historically, I wanted to use
> > -Wtabs as you expected, but there was too much wailing on
> > the gfortran lists, so it was changed to -Wno-tabs with the
> > meaning that "no tabs are allowed" in the context of the
> > Fortran character set. You'll notice that tabs within
> > a literal character string are not flagged.
>
> I cannot understand the rationale of this choice, but I guess it's too late to
> change it!-(
>
> > The history of -Wtabs verse -Wno-tabs can be found in the mailinglist
> > archive.
>
> No interest to dig the archives on this issue.
http://gcc.gnu.org/ml/fortran/2006-03/msg00226.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/58001] Make it possible to silence "Extension: Tab character in format" warning
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
` (7 preceding siblings ...)
2013-07-30 19:07 ` sgk at troutmask dot apl.washington.edu
@ 2013-07-31 19:37 ` sgk at troutmask dot apl.washington.edu
8 siblings, 0 replies; 10+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2013-07-31 19:37 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-07-31 19:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-27 10:36 [Bug fortran/58001] New: Make it possible to silence "Extension: Tab character in format" warning burnus at gcc dot gnu.org
2013-07-27 14:55 ` [Bug fortran/58001] " kargl at gcc dot gnu.org
2013-07-30 12:59 ` dominiq at lps dot ens.fr
2013-07-30 17:42 ` sgk at troutmask dot apl.washington.edu
2013-07-30 17:58 ` dominiq at lps dot ens.fr
2013-07-30 17:59 ` dominiq at lps dot ens.fr
2013-07-30 18:02 ` sgk at troutmask dot apl.washington.edu
2013-07-30 18:16 ` dominiq at lps dot ens.fr
2013-07-30 19:07 ` sgk at troutmask dot apl.washington.edu
2013-07-31 19:37 ` sgk at troutmask dot apl.washington.edu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).