public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1588] PR modula2/110019 Reported line numbers off by 1 when cpp invoked.
@ 2023-06-07 0:22 Gaius Mulley
0 siblings, 0 replies; only message in thread
From: Gaius Mulley @ 2023-06-07 0:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:29c82c6ca929e0f5eccfe038dea71177d814c6b7
commit r14-1588-g29c82c6ca929e0f5eccfe038dea71177d814c6b7
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Wed Jun 7 01:21:19 2023 +0100
PR modula2/110019 Reported line numbers off by 1 when cpp invoked.
Fix off by one in m2.flex when the line number is set via cpp.
gcc/m2/ChangeLog:
PR modula2/110019
* gm2-compiler/SymbolKey.mod (SearchAndDo): Reformatted.
(ForeachNodeDo): Reformatted.
* gm2-compiler/SymbolTable.mod (AddListify): Join list
with "," or "and" if more than one word is in the list.
* m2.flex: Remove -1 from atoi(yytext) line number.
gcc/testsuite/ChangeLog:
PR modula2/110019
* gm2/cpp/fail/cpp-fail.exp: New test.
* gm2/cpp/fail/foocpp.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diff:
---
gcc/m2/gm2-compiler/SymbolKey.mod | 8 +++----
gcc/m2/gm2-compiler/SymbolTable.mod | 14 ++++++++-----
gcc/m2/m2.flex | 2 +-
gcc/testsuite/gm2/cpp/fail/cpp-fail.exp | 37 +++++++++++++++++++++++++++++++++
gcc/testsuite/gm2/cpp/fail/foocpp.mod | 5 +++++
5 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/gcc/m2/gm2-compiler/SymbolKey.mod b/gcc/m2/gm2-compiler/SymbolKey.mod
index b9fa87fa851..fa112665be4 100644
--- a/gcc/m2/gm2-compiler/SymbolKey.mod
+++ b/gcc/m2/gm2-compiler/SymbolKey.mod
@@ -312,7 +312,7 @@ END SearchForAny ;
PROCEDURE ForeachNodeDo (t: SymbolTree; P: PerformOperation) ;
BEGIN
- SearchAndDo(t^.Left, P)
+ SearchAndDo (t^.Left, P)
END ForeachNodeDo ;
@@ -327,9 +327,9 @@ BEGIN
IF t#NIL
THEN
WITH t^ DO
- SearchAndDo(Right, P) ;
- P(KeySym) ;
- SearchAndDo(Left, P)
+ SearchAndDo (Right, P) ;
+ P (KeySym) ;
+ SearchAndDo (Left, P)
END
END
END SearchAndDo ;
diff --git a/gcc/m2/gm2-compiler/SymbolTable.mod b/gcc/m2/gm2-compiler/SymbolTable.mod
index f43a734acbe..1ea5fee9d3e 100644
--- a/gcc/m2/gm2-compiler/SymbolTable.mod
+++ b/gcc/m2/gm2-compiler/SymbolTable.mod
@@ -9028,12 +9028,16 @@ VAR
PROCEDURE AddListify (sym: CARDINAL) ;
BEGIN
INC (ListifyWordCount) ;
- IF ListifyWordCount = ListifyTotal
+ (* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d\n",
+ ListifyWordCount, ListifyTotal) ; *)
+ IF ListifyWordCount > 1
THEN
- ListifySentance := ConCat (ListifySentance, Mark (InitString (" and ")))
- ELSIF ListifyWordCount > 1
- THEN
- ListifySentance := ConCat (ListifySentance, Mark (InitString (", ")))
+ IF ListifyWordCount = ListifyTotal
+ THEN
+ ListifySentance := ConCat (ListifySentance, Mark (InitString (" and ")))
+ ELSE
+ ListifySentance := ConCat (ListifySentance, Mark (InitString (", ")))
+ END
END ;
ListifySentance := ConCat (ListifySentance,
Mark (InitStringCharStar (KeyToCharStar (GetSymName (sym)))))
diff --git a/gcc/m2/m2.flex b/gcc/m2/m2.flex
index 0f23a3585fd..0e6b52c8391 100644
--- a/gcc/m2/m2.flex
+++ b/gcc/m2/m2.flex
@@ -163,7 +163,7 @@ extern void yylex (void);
^\#.* { consumeLine(); /* printf("found: %s\n", currentLine->linebuf); */ BEGIN LINE0; }
\n\#.* { consumeLine(); /* printf("found: %s\n", currentLine->linebuf); */ BEGIN LINE0; }
<LINE0>\#[ \t]* { updatepos(); }
-<LINE0>[0-9]+[ \t]*\" { updatepos(); lineno=atoi(yytext)-1; BEGIN LINE1; }
+<LINE0>[0-9]+[ \t]*\" { updatepos(); lineno=atoi(yytext); BEGIN LINE1; }
<LINE0>\n { m2flex_M2Error("missing initial quote after #line directive"); resetpos(); BEGIN INITIAL; }
<LINE0>[^\n]
<LINE1>[^\"\n]+ { m2flex_M2Error("missing final quote after #line directive"); resetpos(); BEGIN INITIAL; }
diff --git a/gcc/testsuite/gm2/cpp/fail/cpp-fail.exp b/gcc/testsuite/gm2/cpp/fail/cpp-fail.exp
new file mode 100644
index 00000000000..343a3960c77
--- /dev/null
+++ b/gcc/testsuite/gm2/cpp/fail/cpp-fail.exp
@@ -0,0 +1,37 @@
+# Expect driver script for GCC Regression Tests
+# Copyright (C) 2003-2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was written by Gaius Mulley (gaius.mulley@southwales.ac.uk)
+# for GNU Modula-2.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# load support procs
+load_lib gm2-torture.exp
+
+gm2_init_pim "${srcdir}/gm2/pim/fail" -fcpp
+
+foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/foocpp.mod]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $testcase] then {
+ continue
+ }
+
+ gm2-torture-fail $testcase
+}
diff --git a/gcc/testsuite/gm2/cpp/fail/foocpp.mod b/gcc/testsuite/gm2/cpp/fail/foocpp.mod
new file mode 100644
index 00000000000..8d95fc05751
--- /dev/null
+++ b/gcc/testsuite/gm2/cpp/fail/foocpp.mod
@@ -0,0 +1,5 @@
+MODULE foo;
+
+BEGIN
+ i := 0;
+END foo.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-07 0:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 0:22 [gcc r14-1588] PR modula2/110019 Reported line numbers off by 1 when cpp invoked Gaius Mulley
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).