aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-16 22:18:49 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-16 22:18:49 +0100
commit985a72168a64267df8ad4c73337b3f678787174e (patch)
tree0369523f0acf587871766814d44fbe1aedb85986 /gcc
parent0581f5b2ad38ddee2b7de73b0e0efa101d60183a (diff)
downloadgcc-985a72168a64267df8ad4c73337b3f678787174e.zip
gcc-985a72168a64267df8ad4c73337b3f678787174e.tar.gz
gcc-985a72168a64267df8ad4c73337b3f678787174e.tar.bz2
re PR fortran/89724 (Fortran diagnostics give wrong line number because of math-vector-fortran.h header file)
PR fortran/89724 * scanner.c (load_line): Remove linenum and current_line static variables, add warned_tabs automatic variable. Use current_file->line instead of current_line and warned_tabs boolean to avoid diagnosing tabs multiple times on the same line. * gfortran.dg/continuation_15.f90: New test. * gfortran.dg/continuation_16.f90: New test. From-SVN: r269734
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/scanner.c13
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/continuation_15.f909
-rw-r--r--gcc/testsuite/gfortran.dg/continuation_16.f9010
5 files changed, 39 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 614694a..762da70 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2019-03-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/89724
+ * scanner.c (load_line): Remove linenum and current_line static
+ variables, add warned_tabs automatic variable. Use current_file->line
+ instead of current_line and warned_tabs boolean to avoid diagnosing
+ tabs multiple times on the same line.
+
2019-03-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84394
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index eeba2ab..e54d483 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1738,12 +1738,12 @@ gfc_gobble_whitespace (void)
static int
load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char)
{
- static int linenum = 0, current_line = 1;
int c, maxlen, i, preprocessor_flag, buflen = *pbuflen;
int trunc_flag = 0, seen_comment = 0;
int seen_printable = 0, seen_ampersand = 0, quoted = ' ';
gfc_char_t *buffer;
bool found_tab = false;
+ bool warned_tabs = false;
/* Determine the maximum allowed line length. */
if (gfc_current_form == FORM_FREE)
@@ -1793,10 +1793,10 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char)
{
if (pedantic)
gfc_error_now ("%<&%> not allowed by itself in line %d",
- current_line);
+ current_file->line);
else
gfc_warning_now (0, "%<&%> not allowed by itself in line %d",
- current_line);
+ current_file->line);
}
break;
}
@@ -1850,12 +1850,12 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char)
{
found_tab = true;
- if (warn_tabs && seen_comment == 0 && current_line != linenum)
+ if (warn_tabs && seen_comment == 0 && !warned_tabs)
{
- linenum = current_line;
+ warned_tabs = true;
gfc_warning_now (OPT_Wtabs,
"Nonconforming tab character in column %d "
- "of line %d", i+1, linenum);
+ "of line %d", i + 1, current_file->line);
}
while (i < 6)
@@ -1934,7 +1934,6 @@ next_char:
*buffer = '\0';
*pbuflen = buflen;
- current_line++;
return trunc_flag;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d52a648..905791d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/89724
+ * gfortran.dg/continuation_15.f90: New test.
+ * gfortran.dg/continuation_16.f90: New test.
+
2019-03-16 John David Anglin <danglin@gcc.gnu.org>
* g++.dg/cpp0x/pr84497.C: Restore dg-require-weak.
diff --git a/gcc/testsuite/gfortran.dg/continuation_15.f90 b/gcc/testsuite/gfortran.dg/continuation_15.f90
new file mode 100644
index 0000000..ad9dc65
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/continuation_15.f90
@@ -0,0 +1,9 @@
+! PR fortran/89724
+! { dg-do compile }
+! { dg-options "-std=f95" }
+
+include 'continuation_9.f90'
+
+! { dg-warning "not allowed by itself in line 3" "" { target *-*-* } 0 }
+! { dg-warning "not allowed by itself in line 4" "" { target *-*-* } 0 }
+! { dg-warning "not allowed by itself in line 5" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/continuation_16.f90 b/gcc/testsuite/gfortran.dg/continuation_16.f90
new file mode 100644
index 0000000..56d2bbe
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/continuation_16.f90
@@ -0,0 +1,10 @@
+! PR fortran/89724
+! { dg-do compile }
+! { dg-options "-std=f95 -nostdinc -fpre-include=simd-builtins-1.h" }
+ &
+&
+ &
+end
+! { dg-warning "not allowed by itself in line 4" "" { target *-*-* } 0 }
+! { dg-warning "not allowed by itself in line 5" "" { target *-*-* } 0 }
+! { dg-warning "not allowed by itself in line 6" "" { target *-*-* } 0 }